Skip to content

Commit

Permalink
Merge pull request swiftlang#2449 from compnerd/curl-config
Browse files Browse the repository at this point in the history
build: prefer CONFIG over MODULE for CURL
  • Loading branch information
millenomi authored Aug 20, 2019
2 parents ccca1c3 + b648953 commit 6062c49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ option(FOUNDATION_PATH_TO_LIBDISPATCH_SOURCE "Path to libdispatch source" "")
option(FOUNDATION_PATH_TO_LIBDISPATCH_BUILD "Path to libdispatch build" "")
option(FOUNDATION_PATH_TO_XCTEST_BUILD "Path to XCTest build" "")

find_package(CURL REQUIRED)
find_package(CURL CONFIG)
if(CURL_FOUND)
include(CMakeExpandImportedTargets)
cmake_expand_imported_targets(CURL_LIBRARIES LIBRARIES CURL::libcurl)
else()
find_package(CURL REQUIRED)
endif()
find_package(ICU COMPONENTS uc i18n REQUIRED)
find_package(LibXml2 REQUIRED)

Expand Down
12 changes: 10 additions & 2 deletions CoreFoundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,15 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_include_directories(CFXMLInterface
PRIVATE
${LIBXML2_INCLUDE_DIR})
find_package(CURL REQUIRED)
find_package(CURL CONFIG)
if(NOT CURL_FOUND)
find_package(CURL REQUIRED)
if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LOCATION ${CURL_LIBRARIES})
endif()
endif()
target_include_directories(CFURLSessionInterface
PRIVATE
${CURL_INCLUDE_DIRS})
Expand Down Expand Up @@ -617,7 +625,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
${LIBXML2_LIBRARIES})
target_link_libraries(CFURLSessionInterface
PRIVATE
${CURL_LIBRARIES})
CURL::libcurl)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Android)
target_link_libraries(CoreFoundation
Expand Down

0 comments on commit 6062c49

Please sign in to comment.