Skip to content

Commit ee3d71f

Browse files
committed
cmake: fix include ordering issues with bundled deps
When linking against bundled libraries, we include their header directories by using "-isystem". The reason for that is that we want to handle our vendored library headers specially, most importantly to ignore warnings generated by including them. By using "-isystem", though, we screw up the order of searched include directories by moving those bundled dependencies towards the end of the lookup order. Like this, chances are high that any other specified include directory contains a file that collides with the actual desired include file. Fix this by not treating the bundled dependencies' include directories as system includes. This will move them to the front of the lookup order and thus cause them to override system-provided headers. While this may cause the compiler to generate additional warnings when processing bundled headers, this is a tradeoff we should make regardless to fix builds on systems hitting this issue.
1 parent 13cb9f7 commit ee3d71f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ IF(NOT HAVE_REGCOMP_L)
6060
CHECK_FUNCTION_EXISTS(regcomp HAVE_REGCOMP)
6161
IF(NOT HAVE_REGCOMP)
6262
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/regex" "${libgit2_BINARY_DIR}/deps/regex")
63-
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/regex")
63+
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/regex")
6464
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:regex>)
6565
ENDIF()
6666
ENDIF()
@@ -129,7 +129,7 @@ IF (WIN32 AND WINHTTP)
129129
IF (MINGW)
130130
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
131131
LIST(APPEND LIBGIT2_LIBS winhttp)
132-
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
132+
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
133133
ELSE()
134134
LIST(APPEND LIBGIT2_LIBS "winhttp")
135135
LIST(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
@@ -316,7 +316,7 @@ IF (USE_EXT_HTTP_PARSER AND HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUA
316316
ELSE()
317317
MESSAGE(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
318318
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")
319-
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
319+
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
320320
LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
321321
ADD_FEATURE_INFO(http-parser ON "http-parser support (bundled)")
322322
ENDIF()
@@ -340,7 +340,7 @@ IF(NOT USE_BUNDLED_ZLIB)
340340
ENDIF()
341341
IF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
342342
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
343-
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
343+
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
344344
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
345345
ADD_FEATURE_INFO(zlib ON "using bundled zlib")
346346
ENDIF()

0 commit comments

Comments
 (0)