diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeCCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeCUDACompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeCXXCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerABI.cmake | 13 | ||||
-rw-r--r-- | Modules/CMakeParseImplicitIncludeInfo.cmake | 95 |
5 files changed, 111 insertions, 0 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index e75c74e..f473b0d 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -69,6 +69,7 @@ endif() @CMAKE_C_SYSROOT_FLAG_CODE@ @CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ +set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index feb3e79..711129a 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -23,6 +23,7 @@ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBR set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") +set(CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES@") set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 5f52fd8..a1be02b 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -72,6 +72,7 @@ endif() @CMAKE_CXX_SYSROOT_FLAG_CODE@ @CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ +set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@") set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 1dbd44f..e55b83f 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -6,6 +6,7 @@ # This is used internally by CMake and should not be included by user # code. +include(${CMAKE_ROOT}/Modules/CMakeParseImplicitIncludeInfo.cmake) include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) include(CMakeTestCompilerCommon) @@ -87,6 +88,18 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) set(CMAKE_${lang}_COMPILER_ABI "${ABI_NAME}" PARENT_SCOPE) endif() + # Parse implicit include directory for this language, if available. + set (implicit_incdirs "") + if(CMAKE_${lang}_VERBOSE_FLAG) + 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) + endif() + endif() + # Parse implicit linker information for this language, if available. set(implicit_dirs "") set(implicit_libs "") diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake new file mode 100644 index 0000000..9901fea --- /dev/null +++ b/Modules/CMakeParseImplicitIncludeInfo.cmake @@ -0,0 +1,95 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This is used internally by CMake and should not be included by user code. + +# helper function that parses implicit include dirs from a single line +# for compilers that report them that way. on success we return the +# list of dirs in id_var and set state_var to the 'done' state. +function(cmake_parse_implicit_include_line line lang id_var log_var state_var) + # clear variables we append to (avoids possible polution from parent scopes) + unset(rv) + set(log "") + + # ccfe: cray compiler front end (PrgEnv-cray) + if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "Cray" AND + "${line}" MATCHES "-isystem") + string(REGEX MATCHALL " (-I ?|-isystem )([^ ]*)" incs "${line}") + foreach(inc IN LISTS incs) + string(REGEX REPLACE " (-I ?|-isystem )([^ ]*)" "\\2" idir "${inc}") + list(APPEND rv "${idir}") + endforeach() + if(rv) + string(APPEND log " got implicit includes via cray ccfe parser!\n") + else() + string(APPEND log " warning: cray ccfe parse failed!\n") + endif() + endif() + + if(log) + set(${log_var} "${log}" PARENT_SCOPE) + endif() + if(rv) + set(${id_var} "${rv}" PARENT_SCOPE) + set(${state_var} "done" PARENT_SCOPE) + endif() +endfunction() + +# top-level function to parse implicit include directory information +# from verbose compiler output. sets state_var in parent to 'done' on success. +function(cmake_parse_implicit_include_info text lang dir_var log_var state_var) + set(state start) # values: start, loading, done + + # clear variables we append to (avoids possible polution from parent scopes) + set(implicit_dirs_tmp) + set(log "") + + # go through each line of output... + string(REGEX REPLACE "\r?\n" ";" output_lines "${text}") + foreach(line IN LISTS output_lines) + if(state STREQUAL start) + string(FIND "${line}" "#include <...> search starts here:" rv) + if(rv GREATER -1) + set(state loading) + string(APPEND log " found start of implicit include info\n") + else() + cmake_parse_implicit_include_line("${line}" "${lang}" implicit_dirs_tmp + linelog state) + if(linelog) + string(APPEND log ${linelog}) + endif() + if(state STREQUAL done) + break() + endif() + endif() + elseif(state STREQUAL loading) + string(FIND "${line}" "End of search list." rv) + if(rv GREATER -1) + set(state done) + string(APPEND log " end of search list found\n") + break() + else() + string(STRIP "${line}" path) # remove leading/trailing spaces + if ("${path}" MATCHES " \\(framework directory\\)$") + continue() # frameworks are handled elsewhere, ignore them here + endif() + string(REPLACE "\\" "/" path "${path}") + list(APPEND implicit_dirs_tmp "${path}") + string(APPEND log " add: [${path}]\n") + endif() + endif() + endforeach() + + # Log results. + if(state STREQUAL done) + string(APPEND log " implicit include dirs: [${implicit_dirs_tmp}]\n") + else() + string(APPEND log " warn: unable to parse implicit include dirs!\n") + endif() + + # Return results. + set(${dir_var} "${implicit_dirs_tmp}" PARENT_SCOPE) + set(${log_var} "${log}" PARENT_SCOPE) + set(${state_var} "${state}" PARENT_SCOPE) + +endfunction() |