2
0
mirror of https://github.com/curl/curl.git synced 2025-04-24 16:40:32 +08:00

cmake: use INCLUDE_DIRECTORIES prop to specify local header dirs

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 

Closes 
This commit is contained in:
Viktor Szakats 2025-04-08 11:01:09 +02:00
parent 625f2c1644
commit 304b01b8cf
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
3 changed files with 10 additions and 9 deletions

@ -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)

@ -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()

@ -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})