From 486c2937dd88ed42adeb98be4f668b2821a2749b Mon Sep 17 00:00:00 2001 From: Mischan Toosarani-Hausberger Date: Sat, 4 Feb 2023 12:42:15 +0100 Subject: [PATCH] fix: make sure we reuse already found libcurl --- util/CMakeLists.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 9789ce58b..426e2461f 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -246,9 +246,22 @@ endif() if(LINUX OR ANDROID) if (LINUX) - find_package(CURL REQUIRED) - target_include_directories(crashpad_util PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(crashpad_util PRIVATE ${CURL_LIBRARIES}) + if(NOT CURL_FOUND) # Some other lib might bring libcurl already + find_package(CURL REQUIRED) + endif() + + if(TARGET CURL::libcurl) # Only available in cmake 3.12+ + target_link_libraries(crashpad_util PRIVATE CURL::libcurl) + else() + # Needed for cmake < 3.12 support (cmake 3.12 introduced the target CURL::libcurl) + target_include_directories(crashpad_util 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(crashpad_util PRIVATE $) + target_compile_definitions(crashpad_util PRIVATE $) + endif() + SET(HTTP_TRANSPORT_IMPL net/http_transport_libcurl.cc) else() SET(HTTP_TRANSPORT_IMPL net/http_transport_socket.cc)