Skip to content

Commit

Permalink
CMake: Check whether libcurl was already found (#602)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ladislavmacoun authored Oct 22, 2021
1 parent 779da12 commit 491ea58
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 491ea58

Please sign in to comment.