Skip to content

Commit

Permalink
cmake: bring curl-config.cmake closer to FindCURL
Browse files Browse the repository at this point in the history
Set `CURL_LIBRARIES` and `CURL_INCLUDE_DIRS` variables
for compatibility with CMake's `FindCURL.cmake`:
https://github.com/Kitware/CMake/blob/b411d0146c2e06acfb0c823bb039e99f0191b611/Modules/FindCURL.cmake#L209

For dependent projects, CMake's suggestion is to replace
`CURL_LIBRARIES` with `CURL::libcurl`, and drop `CURL_INCLUDE_DIRS`.

Reported-by: Aurélien Pierre
Ref: https://curl.se/mail/lib-2024-06/0014.html
Ref: https://gitlab.kitware.com/cmake/cmake/-/issues/24580
Closes #13897
  • Loading branch information
vszakats committed Jun 13, 2024
1 parent 410111b commit 1dec702
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMake/curl-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 38,7 @@ check_required_components("@PROJECT_NAME@")
if(NOT TARGET @PROJECT_NAME@::libcurl)
add_library(@PROJECT_NAME@::libcurl ALIAS @PROJECT_NAME@::@LIB_SELECTED@)
endif()

# For compatibility with CMake's FindCURL.cmake
set(CURL_LIBRARIES @PROJECT_NAME@::libcurl)
set_and_check(CURL_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 1855,7 @@ if(NOT CURL_DISABLE_INSTALL)
configure_package_config_file(CMake/curl-config.cmake.in
"${project_config}"
INSTALL_DESTINATION ${CURL_INSTALL_CMAKE_DIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)

if(CURL_ENABLE_EXPORT_TARGET)
Expand Down

0 comments on commit 1dec702

Please sign in to comment.