• chuck cranor's avatar
    ParseImplicitIncludeInfo: keep implicit incl. consistent when rerunning cmake · 1293ed85
    chuck cranor authored
    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.
    1293ed85
UnixPaths.cmake 2.61 KB