]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: bring `curl-config.cmake` closer to `FindCURL`
authorViktor Szakats <commit@vsz.me>
Wed, 5 Jun 2024 20:35:48 +0000 (22:35 +0200)
committerViktor Szakats <commit@vsz.me>
Thu, 13 Jun 2024 09:17:32 +0000 (11:17 +0200)
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

CMake/curl-config.cmake.in
CMakeLists.txt

index 9adb96e0aa6866e138975e57e6be5e7e9fae8c04..2ce8625ef90b3d0b4023c7582d3c8fe7c7e09ba8 100644 (file)
@@ -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@")
index ebbe2b1a1d06833a864b521c5f3282caff741a71..c939df914c689f34919cb324336f4140ff77fec9 100644 (file)
@@ -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)