]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: use `INCLUDE_DIRECTORIES` prop to specify local header dirs
authorViktor Szakats <commit@vsz.me>
Tue, 8 Apr 2025 09:01:09 +0000 (11:01 +0200)
committerViktor Szakats <commit@vsz.me>
Tue, 8 Apr 2025 17:09:58 +0000 (19:09 +0200)
To use more modern cmake, and make it somewhat more obvious where these
header directories should apply.

Also move setting the directory property _before_ defining targets,
to make them inherit this directory property.

Ref: https://cmake.org/cmake/help/latest/command/include_directories.html
Ref: https://cmake.org/cmake/help/latest/prop_dir/INCLUDE_DIRECTORIES.html

Follow-up to 45f7cb7695b0fe0c61f71bdfbe31d161d50a5f51 #16238

Closes #16993

CMakeLists.txt
lib/CMakeLists.txt
src/CMakeLists.txt

index 7edaf518b86188336009e8e9cf72697be7a25ab9..a0ab0b184fb512c899dea5628f27237457341e91 100644 (file)
@@ -190,7 +190,7 @@ else()
   set(CURL_OS "\"${CMAKE_SYSTEM_NAME}\"")
 endif()
 
-include_directories("${PROJECT_SOURCE_DIR}/include")
+set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES "${PROJECT_SOURCE_DIR}/include")
 
 if(NOT DEFINED CMAKE_UNITY_BUILD_BATCH_SIZE)
   set(CMAKE_UNITY_BUILD_BATCH_SIZE 0)
index 8369138833e5eaebe0a03209977acfdee3d7310f..3e87198960badd4eda2339eae420a7ba9ca2fa32 100644 (file)
@@ -36,7 +36,8 @@ list(APPEND HHEADERS "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h")
 
 # The rest of the build
 
-include_directories("${PROJECT_BINARY_DIR}/lib")  # for "curl_config.h"
+set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR}/lib")  # for "curl_config.h"
+
 if(USE_ARES)
   include_directories(SYSTEM ${CARES_INCLUDE_DIRS})
 endif()
index a0b700bce4160894a380d07ec8ea7ef053f6bc40..3bf66091e32ce2a65ff5c95b1f7ed01e56ba6fb2 100644 (file)
@@ -77,6 +77,13 @@ if(BUILD_STATIC_CURL)
   set(CURLX_CFILES ${CURLTOOL_LIBCURL_CFILES})
 endif()
 
+set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
+  "${PROJECT_BINARY_DIR}/lib"  # for "curl_config.h"
+  "${PROJECT_SOURCE_DIR}/lib"  # for "curl_setup.h"
+  # This is needed as tool_hugehelp.c is generated in the binary dir
+  "${PROJECT_SOURCE_DIR}/src"  # for "tool_hugehelp.h"
+)
+
 add_executable(
   ${EXE_NAME}
   ${CURL_CFILES} ${_curl_cfiles_gen} ${CURLX_CFILES} ${CURL_HFILES} ${_curl_hfiles_gen}
@@ -109,13 +116,6 @@ source_group("curlX source files" FILES ${CURLX_CFILES})
 source_group("curl source files" FILES ${CURL_CFILES} ${_curl_cfiles_gen})
 source_group("curl header files" FILES ${CURL_HFILES} ${_curl_hfiles_gen})
 
-include_directories(
-  "${PROJECT_BINARY_DIR}/lib"  # for "curl_config.h"
-  "${PROJECT_SOURCE_DIR}/lib"  # for "curl_setup.h"
-  # This is needed as tool_hugehelp.c is generated in the binary dir
-  "${PROJECT_SOURCE_DIR}/src"  # for "tool_hugehelp.h"
-)
-
 # Build curl executable
 target_link_libraries(${EXE_NAME} ${LIB_SELECTED_FOR_EXE} ${CURL_LIBS})