]> granicus.if.org Git - curl/commitdiff
CMake: CMake config files are defining CURL_STATICLIB for static builds
authorAdrien <Adnn@users.noreply.github.com>
Wed, 1 Aug 2018 12:02:26 +0000 (14:02 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 15 Aug 2018 11:45:27 +0000 (13:45 +0200)
This change allows to use the CMake config files generated by Curl's
CMake scripts for static builds of the library.
The symbol CURL_STATIC lib must be defined to compile downstream,
thus the config package is the perfect place to do so.

Fixes #2817
Closes #2823
Reported-by: adnn on github
Reviewed-by: Sergei Nikulov
lib/CMakeLists.txt

index 306ba1a6ea5aa9997c403524af2fe9e0d6532be8..87cbe8174cbc17d6b6d657482af9fb4003d8e312 100644 (file)
@@ -76,6 +76,10 @@ if(MSVC AND NOT BUILD_SHARED_LIBS)
   set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
 endif()
 
+if(NOT BUILD_SHARED_LIBS)
+    set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB)
+endif()
+
 target_link_libraries(${LIB_NAME} ${CURL_LIBS})
 
 if(WIN32)