diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 15fbd18..c6cfd11 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,8 +14,20 @@ endif() rttr_set_output_dir(RUNTIME ${RTTR_EXTRA_BINDIR}) add_executable(s25update ${_sources}) -target_include_directories(s25update SYSTEM PRIVATE ${CURL_INCLUDE_DIRS}) -target_link_libraries(s25update PRIVATE s25util::common ${CURL_LIBRARIES} BZip2::BZip2 Boost::filesystem Boost::nowide Boost::disable_autolinking) + +if (TARGET CURL::libcurl AND CURL_CONFIG) + target_link_libraries(s25update PRIVATE CURL::libcurl) +else() + target_include_directories(s25update SYSTEM PRIVATE ${CURL_INCLUDE_DIRS}) + target_link_libraries(s25update PRIVATE ${CURL_LIBRARIES}) + # Heuristic if CURL is a static library and we need to add the define + if(CURL_LIBRARIES MATCHES "\.a$" OR CURL_LIBRARIES MATCHES "curl_a" OR (WIN32 AND NOT CURL_LIBRARIES MATCHES "_imp\.lib")) + target_compile_definitions(s25update PRIVATE "CURL_STATICLIB") + endif() +endif() + +target_include_directories(s25update SYSTEM PRIVATE) +target_link_libraries(s25update PRIVATE s25util::common BZip2::BZip2 Boost::filesystem Boost::nowide Boost::disable_autolinking) target_compile_features(s25update PRIVATE cxx_std_17) if(NOT PLATFORM_NAME OR NOT PLATFORM_ARCH) message(FATAL_ERROR "PLATFORM_NAME or PLATFORM_ARCH not set")