diff options
author | Chuck Cranor <chuck@ece.cmu.edu> | 2019-01-30 19:05:21 (GMT) |
---|---|---|
committer | Chuck Cranor <chuck@ece.cmu.edu> | 2019-01-30 19:05:21 (GMT) |
commit | 1293ed8507be7e854dcb9437a5b7062ec740ff69 (patch) | |
tree | 9689a331672c5878c48d6973f1eee42db76016e8 /Modules/CMakeDetermineCompilerABI.cmake | |
parent | eaf53158f49e6e7581613376e8c054e18bdffc23 (diff) | |
download | CMake-1293ed8507be7e854dcb9437a5b7062ec740ff69.zip CMake-1293ed8507be7e854dcb9437a5b7062ec740ff69.tar.gz CMake-1293ed8507be7e854dcb9437a5b7062ec740ff69.tar.bz2 |
ParseImplicitIncludeInfo: keep implicit incl. consistent when rerunning cmake
The first time you run cmake, it sets the implicit include path
to the value reported by the parser (and this value gets saved
in CMake${lang}Compiler.cmake). But if you re-run cmake,
UnixPaths.cmake blindly appends an extra /usr/include to the
value saved in CMake${lang}Compiler.cmake. That should not be
harmful in most cases, but we want later runs of cmake to be
consistent with the initial one. Resolve using a solution
suggested by Brad King:
- UnixPaths now sets the default implicit include path in a new
variable named _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT
This value is only used the first time cmake is run (by
CMakeDetermineCompilerABI.cmake when it calls the implicit
include parser).
- if CMakeDetermineCompilerABI.cmake successfully calls the
implicit include parser, it overwrites the value in
_CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT with the
value returned by the parser
- CMakeDetermineCompilerABI.cmake always sets
CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES to the above value
of _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT
- the final value of CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES gets
saved to CMake${lang}Compiler.cmake when it is regenerated after
the compiler tests are done.
- CMakeDetermineCompilerABI.cmake is only executed the first time cmake
is run. Additional runs of cmake directly load the implicit include
path from the value saved in CMake${lang}Compiler.cmake (the parser
and _INIT variable are not used).
The above depends on UnixPaths.cmake being loaded to set the _INIT value
before CMakeDetermineCompilerABI.cmake runs the implicit include parser.
Diffstat (limited to 'Modules/CMakeDetermineCompilerABI.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerABI.cmake | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index e55b83f..fd1d5fb 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -89,16 +89,18 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) endif() # Parse implicit include directory for this language, if available. - set (implicit_incdirs "") if(CMAKE_${lang}_VERBOSE_FLAG) + set (implicit_incdirs "") cmake_parse_implicit_include_info("${OUTPUT}" "${lang}" implicit_incdirs log rv) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Parsed ${lang} implicit include dir info from above output: rv=${rv}\n${log}\n\n") - if("${rv}" STREQUAL "done") # update parent if parse completed ok - set(CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "${implicit_incdirs}" PARENT_SCOPE) + if("${rv}" STREQUAL "done") + # We parsed implicit include directories, so override the default initializer. + set(_CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT "${implicit_incdirs}") endif() endif() + set(CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "${_CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT}" PARENT_SCOPE) # Parse implicit linker information for this language, if available. set(implicit_dirs "") |