Commit 8a43161b6b55f6ef434c7add945ee63cabfb0684

Patrick Steinhardt 2017-07-05T12:18:17

cmake: always include our own headers first With c26ce7840 (Merge branch 'AndreyG/cmake/modernization', 2017-06-28), we have recently introduced a regression in the way we are searching for headers. We have made sure to always include our own headers first, but due to the changes in c26ce7840 this is no longer guaranteed. In fact, this already leads the compiler into picking "config.h" from the "deps/regex" dependency, if it is used. Fix the issue by declaring our internal include directories up front, before any of the other search directories is added.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7e434a2..c63f45c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,10 @@ SET(LIBGIT2_PC_REQUIRES "")
 # pc file.
 SET(LIBGIT2_PC_LIBS "")
 
-SET(LIBGIT2_INCLUDES "")
+SET(LIBGIT2_INCLUDES
+	"${CMAKE_CURRENT_BINARY_DIR}"
+	"${CMAKE_SOURCE_DIR}/src"
+	"${CMAKE_SOURCE_DIR}/include")
 SET(LIBGIT2_LIBS "")
 SET(LIBGIT2_LIBDIRS "")
 
@@ -329,8 +332,6 @@ CONFIGURE_FILE(features.h.in git2/sys/features.h)
 
 SET(GIT2INTERNAL_OBJECTS ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
 
-LIST(APPEND LIBGIT2_INCLUDES ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/include")
-
 IF (CMAKE_VERSION VERSION_GREATER 2.8.7)
 	ADD_LIBRARY(git2internal OBJECT ${GIT2INTERNAL_OBJECTS})
 	IDE_SPLIT_SOURCES(git2internal)