Commit 1293ed85 authored by chuck cranor's avatar chuck cranor

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.
parent eaf53158
......@@ -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 "")
......
......@@ -69,14 +69,17 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES
)
# Default per-language values. These may be later replaced after
# parsing the implicit link directories from compiler output.
list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
# parsing the implicit directory information from compiler output.
set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}
/usr/include
)
list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
set(_CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}
/usr/include
)
list(APPEND CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES
set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES}
/usr/include
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment