Ensure local config.h is used if Ceres is already installed. - Previously, if Ceres was already installed to the same location as one of the depenedencies (e.g. /usr/local) then as the BUILD_DIR/config path was necessarily added to the include_directories() list *after* the INCLUDE_DIRS for the dependencies, the config.h for the *installed* version of Ceres would be used instead of the locally configured version, as it would appear first on the path. - Forcing the location of the locally configured config.h to the front of the include_directories() list ensures that it is found first (and is thus used) even if an installed version of Ceres also exists on the path. Change-Id: I7b4f97a3ad0120bd11551f9b8eb6bffc66966eb4
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ae9a5c..4ab2e31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -775,7 +775,12 @@ INCLUDE(CreateCeresConfig) CREATE_CERES_CONFIG("${CERES_COMPILE_OPTIONS}" ${CMAKE_CURRENT_BINARY_DIR}/config/ceres/internal) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/config) +# Force the location containing the configured config.h to the front of the +# include_directories list (by default it is appended to the back) to ensure +# that if the user has an installed version of Ceres in the same location as one +# of the dependencies (e.g. /usr/local) that we find the config.h we just +# configured, not the (older) installed config.h. +INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/config) ADD_SUBDIRECTORY(internal/ceres)