]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: `SHARE_LIB_OBJECT=ON` requires CMake 3.12 or newer
authorViktor Szakats <commit@vsz.me>
Tue, 18 Feb 2025 00:23:40 +0000 (01:23 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 18 Feb 2025 14:05:39 +0000 (15:05 +0100)
This feature requires Object Libraries which is supported by CMake 3.12
or newer: https://cmake.org/cmake/help/latest/release/3.12.html

Keep it permanently disabled for older CMake versions.
Also document it in `docs/INSTALL-CMAKE.md`.

Ref: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#object-libraries

Follow-up to fc9bfb14520712672b4784e8b48256fb29204011 #11627
Follow-up to 2ebc74c36a19a1700af394c16855ce144d9878e3 #11546

Reported-by: Mark Phillips
Fixes #16375
Closes #16376

docs/INSTALL-CMAKE.md
lib/CMakeLists.txt

index 8f19c51cc9eecc31efd8b1ce28ea229d8f7f71e4..e55d951496688bc719de463e56377ae23eaf55f2 100644 (file)
@@ -170,6 +170,7 @@ assumes that CMake generates `Makefile`:
 - `IMPORT_LIB_SUFFIX`:                      Import library suffix. Default: `_imp` for MSVC-like toolchains, otherwise empty.
 - `LIBCURL_OUTPUT_NAME`:                    Basename of the curl library. Default: `libcurl`
 - `PICKY_COMPILER`:                         Enable picky compiler options. Default: `ON`
+- `SHARE_LIB_OBJECT`:                       Build shared and static libcurl in a single pass (requires CMake 3.12 or newer). Default: `ON` for Windows
 - `STATIC_LIB_SUFFIX`:                      Static library suffix. Default: (empty)
 
 ## CA bundle options
index 244835814ae9e01e61468d85bea57585a48e833c..76b63f416ba1c1724cb464c17f69d75569a99b1b 100644 (file)
@@ -106,9 +106,9 @@ if(NOT DEFINED SHARE_LIB_OBJECT)
   endif()
 endif()
 
-if(SHARE_LIB_OBJECT)
+if(SHARE_LIB_OBJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
   set(LIB_OBJECT "libcurl_object")
-  add_library(${LIB_OBJECT} OBJECT ${HHEADERS} ${CSOURCES})
+  add_library(${LIB_OBJECT} OBJECT ${HHEADERS} ${CSOURCES})  # Requires CMake 3.12
   if(WIN32)
     # Define CURL_STATICLIB always, to disable __declspec(dllexport) for
     # exported libcurl symbols. We handle exports via libcurl.def instead.