From d548f8b9d622c347c10b56e69cd6869061995881 Mon Sep 17 00:00:00 2001 From: pastdue <30942300+past-due@users.noreply.github.com> Date: Fri, 16 Jul 2021 20:35:58 -0400 Subject: [PATCH 1/2] CMake: Link to the CURL::libcurl target when available --- CMakeLists.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 696d270ae0..0903b150f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,13 +250,17 @@ target_compile_definitions(sentry PRIVATE SIZEOF_LONG=${CMAKE_SIZEOF_LONG}) if(SENTRY_TRANSPORT_CURL) find_package(CURL REQUIRED) - target_include_directories(sentry PRIVATE ${CURL_INCLUDE_DIR}) - # The exported sentry target must not contain any path of the build machine, therefore use generator expressions - # FIXME: cmake 3.12 introduced the target CURL::libcurl - string(REPLACE ";" "$" GENEX_CURL_LIBRARIES "${CURL_LIBRARIES}") - string(REPLACE ";" "$" GENEX_CURL_COMPILE_DEFINITIONS "${CURL_COMPILE_DEFINITIONS}") - target_link_libraries(sentry PRIVATE $) - target_compile_definitions(sentry PRIVATE $) + if(TARGET CURL::libcurl) # Only available in cmake 3.12+ + target_link_libraries(sentry PRIVATE CURL::libcurl) + else() + # FIXME: Needed for cmake < 3.12 support (cmake 3.12 introduced the target CURL::libcurl) + target_include_directories(sentry PRIVATE ${CURL_INCLUDE_DIR}) + # The exported sentry target must not contain any path of the build machine, therefore use generator expressions + string(REPLACE ";" "$" GENEX_CURL_LIBRARIES "${CURL_LIBRARIES}") + string(REPLACE ";" "$" GENEX_CURL_COMPILE_DEFINITIONS "${CURL_COMPILE_DEFINITIONS}") + target_link_libraries(sentry PRIVATE $) + target_compile_definitions(sentry PRIVATE $) + endif() endif() set_property(TARGET sentry PROPERTY C_VISIBILITY_PRESET hidden) From a7132c4abd1b217ad9f9c79dba9baf85f03b767b Mon Sep 17 00:00:00 2001 From: pastdue <30942300+past-due@users.noreply.github.com> Date: Mon, 19 Jul 2021 11:40:43 -0400 Subject: [PATCH 2/2] Remove obsolete "FIXME" --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0903b150f0..a893ccf78e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,7 +253,7 @@ if(SENTRY_TRANSPORT_CURL) if(TARGET CURL::libcurl) # Only available in cmake 3.12+ target_link_libraries(sentry PRIVATE CURL::libcurl) else() - # FIXME: Needed for cmake < 3.12 support (cmake 3.12 introduced the target CURL::libcurl) + # Needed for cmake < 3.12 support (cmake 3.12 introduced the target CURL::libcurl) target_include_directories(sentry PRIVATE ${CURL_INCLUDE_DIR}) # The exported sentry target must not contain any path of the build machine, therefore use generator expressions string(REPLACE ";" "$" GENEX_CURL_LIBRARIES "${CURL_LIBRARIES}")