]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: cleanup header paths
authorViktor Szakats <commit@vsz.me>
Tue, 6 Aug 2024 09:45:39 +0000 (11:45 +0200)
committerViktor Szakats <commit@vsz.me>
Tue, 6 Aug 2024 20:33:05 +0000 (22:33 +0200)
- sync build-dir/source-dir header path order with autotools, by
  including build-dir first, then source-dir.
  This prevents out-of-tree builds breaking due to leftover generated
  headers in the source tree.

- tests/unit: move `src` ahead of `libtest` in header path, syncing with
  autotools.

- stop adding non-existing generated `include` dir to header path.
  There are no generated `include` headers and this directory is either
  missing in out-of-tree builds or the same as the one already added
  globally via the root `CMakeLists.txt`.

- lib: stop adding a duplicate source include directory to the header
  path.
  It's already added globally via the root `CMakeLists.txt`.

- lib: stop adding the project root to the header path.

- docs/examples: drop internal header paths.
  Examples do not and should not use internal headers.

- replace `curl_setup_once.h` in comments with `curl_setup.h`,
  the header actually used, and also referred to in autotools comments.

- add comment why we need `src` in include path for `tests/server`.

- add quotes around header directories.

Closes #14416

CMakeLists.txt
docs/examples/CMakeLists.txt
lib/CMakeLists.txt
src/CMakeLists.txt
tests/http/clients/CMakeLists.txt
tests/libtest/CMakeLists.txt
tests/server/CMakeLists.txt
tests/unit/CMakeLists.txt

index 181db0bd3b36811e18d76d3a87912b1be9ea6e80..7242d687fcee77930e007fe03001d435b54774b2 100644 (file)
@@ -98,7 +98,7 @@ else()
   set(OS "\"${CMAKE_SYSTEM_NAME}\"")
 endif()
 
-include_directories(${CURL_SOURCE_DIR}/include)
+include_directories("${CURL_SOURCE_DIR}/include")
 
 set(CMAKE_UNITY_BUILD_BATCH_SIZE 0)
 
index b6166dea1e53f9bf03e045030cba8eb4439e80fa..2743667c7e1670c01a2a29ee38128d69fb4b1e7d 100644 (file)
@@ -30,11 +30,6 @@ include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
 foreach(_example IN LISTS check_PROGRAMS)
   set(_example_target "curl-example-${_example}")
   add_executable(${_example_target} "${_example}.c")
-  target_include_directories(${_example_target} PRIVATE
-    "${CURL_SOURCE_DIR}/lib"      # for "curl_setup_once.h"
-    "${CURL_BINARY_DIR}/lib"      # for "curl_config.h"
-    "${CURL_BINARY_DIR}/include"  # for "curl/curl.h"
-  )
   target_link_libraries(${_example_target} ${LIB_SELECTED} ${CURL_LIBS})
   target_compile_definitions(${_example_target} PRIVATE "CURL_NO_OLDIES")
   if(LIB_SELECTED STREQUAL LIB_STATIC AND WIN32)
index 35f30f8725ef4e49071f2e748943c18e149223ba..1b8fb7bb17e683207ad3a84e5010746570068787 100644 (file)
@@ -40,12 +40,8 @@ list(APPEND HHEADERS ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
 # The rest of the build
 
 include_directories(
-  ${CMAKE_CURRENT_BINARY_DIR}/../include
-  ${CMAKE_CURRENT_SOURCE_DIR}/..
-  ${CMAKE_CURRENT_SOURCE_DIR}/../include
-  ${CMAKE_CURRENT_BINARY_DIR}/..
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  ${CMAKE_CURRENT_BINARY_DIR}
+  "${CMAKE_CURRENT_BINARY_DIR}"
+  "${CMAKE_CURRENT_SOURCE_DIR}"
 )
 if(USE_ARES)
   include_directories(${CARES_INCLUDE_DIR})
index 53f1da3682ea4c61a6b6d311e42bb7db30808594..fa79bcdfe8013431e9aefbdb2908cf492ce047c4 100644 (file)
@@ -118,11 +118,10 @@ source_group("curl source files" FILES ${CURL_CFILES})
 source_group("curl header files" FILES ${CURL_HFILES})
 
 include_directories(
-  ${CURL_SOURCE_DIR}/lib      # for "curl_setup_once.h"
-  ${CURL_BINARY_DIR}/lib      # for "curl_config.h"
-  ${CURL_BINARY_DIR}/include  # for "curl/curl.h"
+  "${CURL_BINARY_DIR}/lib"  # for "curl_config.h"
+  "${CURL_SOURCE_DIR}/lib"  # for "curl_setup.h"
   # This is needed as tool_hugehelp.c is generated in the binary dir
-  ${CURL_SOURCE_DIR}/src      # for "tool_hugehelp.h"
+  "${CURL_SOURCE_DIR}/src"  # for "tool_hugehelp.h"
 )
 
 # Build curl executable
index 46d887adb420db436bf2b7b991e5ae4c67e6ea95..dab2d92372120732f5db1b7ef32732890ba999d0 100644 (file)
@@ -31,9 +31,8 @@ foreach(_client IN LISTS check_PROGRAMS)
   add_executable(${_client_target} "${_client}.c")
   add_dependencies(testdeps ${_client_target})
   target_include_directories(${_client_target} PRIVATE
-    "${CURL_SOURCE_DIR}/lib"      # for "curl_setup_once.h"
-    "${CURL_BINARY_DIR}/lib"      # for "curl_config.h"
-    "${CURL_BINARY_DIR}/include"  # for "curl/curl.h"
+    "${CURL_BINARY_DIR}/lib"  # for "curl_config.h"
+    "${CURL_SOURCE_DIR}/lib"  # for "curl_setup.h"
   )
   target_link_libraries(${_client_target} ${LIB_SELECTED} ${CURL_LIBS})
   target_compile_definitions(${_client_target} PRIVATE "CURL_NO_OLDIES")
index 85ac823df7634a4eb7c13887b90141e02e423328..9cb43c098d65071affcd99c0eee799699688dfb7 100644 (file)
@@ -35,10 +35,9 @@ function(setup_test test_name)  # ARGN are the files in the test
   string(TOUPPER ${test_name} UPPER_TEST_NAME)
 
   include_directories(
-    ${CURL_SOURCE_DIR}/lib            # for "curl_setup_once.h"
-    ${CURL_BINARY_DIR}/lib            # for "curl_config.h"
-    ${CURL_BINARY_DIR}/include        # for "curl/curl.h"
-    ${CURL_SOURCE_DIR}/tests/libtest  # to be able to build generated tests
+    "${CURL_BINARY_DIR}/lib"            # for "curl_config.h"
+    "${CURL_SOURCE_DIR}/lib"            # for "curl_setup.h"
+    "${CURL_SOURCE_DIR}/tests/libtest"  # to be able to build generated tests
   )
   if(USE_ARES)
     include_directories(${CARES_INCLUDE_DIR})
index c72cf512d5b0273d482f596bfd1ded6428df4b12..b46c23085e24b8659890f20228068bd7de04ac97 100644 (file)
@@ -32,10 +32,9 @@ function(setup_executable test_name)  # ARGN are the files in the test
   add_dependencies(testdeps ${test_name})
 
   include_directories(
-    ${CURL_SOURCE_DIR}/lib      # for "curl_setup_once.h"
-    ${CURL_BINARY_DIR}/lib      # for "curl_config.h"
-    ${CURL_BINARY_DIR}/include  # for "curl/curl.h"
-    ${CURL_SOURCE_DIR}/src      # for "tool_xattr.h"
+    "${CURL_BINARY_DIR}/lib"  # for "curl_config.h"
+    "${CURL_SOURCE_DIR}/lib"  # for "curl_setup.h"
+    "${CURL_SOURCE_DIR}/src"  # for "tool_xattr.h" in disabled_SOURCES
   )
   if(USE_ARES)
     include_directories(${CARES_INCLUDE_DIR})
index 6ec352f6ef5b63eec9f7e232d9af36a670317cdc..3b99257c426bd6fe8a65f3457b6aa1b496be32a9 100644 (file)
@@ -27,11 +27,10 @@ transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.
 include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
 
 include_directories(
-  ${CURL_SOURCE_DIR}/lib          # for "curl_setup_once.h"
-  ${CURL_SOURCE_DIR}/tests/libtest
-  ${CURL_SOURCE_DIR}/src
-  ${CURL_BINARY_DIR}/lib          # for "curl_config.h"
-  ${CURL_BINARY_DIR}/include      # for "curl/curl.h"
+  "${CURL_BINARY_DIR}/lib"            # for "curl_config.h"
+  "${CURL_SOURCE_DIR}/lib"            # for "curl_setup.h"
+  "${CURL_SOURCE_DIR}/src"
+  "${CURL_SOURCE_DIR}/tests/libtest"
 )
 
 foreach(_testfile IN LISTS UNITPROGS)