From 6f098cbe45a43d9991e8c69fe2fc80a6b63f6a7e Mon Sep 17 00:00:00 2001 From: Ladislav Macoun Date: Thu, 21 Oct 2021 17:25:35 +0200 Subject: [PATCH] CMake: Check whether libcurl was already found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently when there is any other project that brings libcurl as a dependency, the build fails with “Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)“, even though libcurl has already added as CURL::libcurl library. This patch adds a check for CURL_FOUND, to indicate that the library was already found, if set by another project. It also skips the additional find_package() step so it does not fail. Signed-off-by: Ladislav Macoun --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bdc8edfd..4e740ed0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,7 +260,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS400") endif() if(SENTRY_TRANSPORT_CURL) - find_package(CURL REQUIRED) + 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(sentry PRIVATE CURL::libcurl) else()