1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 17:31:57 +08:00

CMakeParseImplicitIncludeInfo: remove needless variable expansions

They seem to actually cause trouble, like an error reported on IRC where some
but not all CMake invocations may end up with an error like this:

   CMake Warning (dev) at /usr/share/cmake/Modules/CMakeParseImplicitIncludeInfo.cmake:74 (if):
     Policy CMP0054 is not set: Only interpret if() arguments as variables or
     keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
     details.  Use the cmake_policy command to set the policy and suppress this
     warning.

     Quoted keywords like ")" will no longer be interpreted as keywords when the
     policy is set to NEW.  Since the policy is not set the OLD behavior will be
     used.
   Call Stack (most recent call first):
     /usr/share/cmake/Modules/CMakeParseImplicitIncludeInfo.cmake:179 (cmake_parse_implicit_include_line)
     /usr/share/cmake/Modules/CMakeDetermineCompilerABI.cmake:119 (cmake_parse_implicit_include_info)
     /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
     CMakeLists.txt:24 (project)
   This warning is for project developers.  Use -Wno-dev to suppress it.

   CMake Error at /usr/share/cmake/Modules/CMakeParseImplicitIncludeInfo.cmake:74 (if):
     if given arguments:

       "GNU" "STREQUAL" "SunPro" "AND" "(" ")" "MATCHES" "-D__SUNPRO_C" "OR" ")" "MATCHES" "-D__SUNPRO_F" ")"

I suspect that the line ends up being just ")", which then causes this error.
This commit is contained in:
Rolf Eike Beer
2021-05-13 15:32:25 +02:00
parent 96011ab06d
commit caea48eec9

View File

@@ -12,9 +12,9 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
set(log "")
# Cray compiler (from cray wrapper, via PrgEnv-cray)
if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "Cray" AND
"${line}" MATCHES "^/" AND "${line}" MATCHES "/ccfe |/ftnfe " AND
"${line}" MATCHES " -isystem| -I")
if(CMAKE_${lang}_COMPILER_ID STREQUAL "Cray" AND
line MATCHES "^/" AND line MATCHES "/ccfe |/ftnfe " AND
line MATCHES " -isystem| -I")
string(REGEX MATCHALL " (-I ?|-isystem )(\"[^\"]+\"|[^ \"]+)" incs "${line}")
foreach(inc IN LISTS incs)
string(REGEX REPLACE " (-I ?|-isystem )(\"[^\"]+\"|[^ \"]+)" "\\2" idir "${inc}")
@@ -28,12 +28,12 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
endif()
# PGI compiler
if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "PGI")
if(CMAKE_${lang}_COMPILER_ID STREQUAL "PGI")
# pgc++ verbose output differs
if(("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "Fortran") AND
"${line}" MATCHES "^/" AND
"${line}" MATCHES "/pgc |/pgf901 |/pgftnc " AND
"${line}" MATCHES " -cmdline ")
if((lang STREQUAL "C" OR lang STREQUAL "Fortran") AND
line MATCHES "^/" AND
line MATCHES "/pgc |/pgf901 |/pgftnc " AND
line MATCHES " -cmdline ")
# cmdline has unparsed cmdline, remove it
string(REGEX REPLACE "-cmdline .*" "" line "${line}")
if("${line}" MATCHES " -nostdinc ")
@@ -51,14 +51,14 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
else()
string(APPEND log " warning: PGI C/F parse failed!\n")
endif()
elseif("${lang}" STREQUAL "CXX" AND "${line}" MATCHES "^/" AND
"${line}" MATCHES "/pggpp1 " AND "${line}" MATCHES " -I")
elseif(lang STREQUAL "CXX" AND line MATCHES "^/" AND
line MATCHES "/pggpp1 " AND line MATCHES " -I")
# oddly, -Mnostdinc does not get rid of system -I's, at least in
# PGI 18.10.1 ...
string(REGEX MATCHALL " (-I ?)([^ ]*)" incs "${line}")
foreach(inc IN LISTS incs)
string(REGEX REPLACE " (-I ?)([^ ]*)" "\\2" idir "${inc}")
if(NOT "${idir}" STREQUAL "-") # filter out "-I-"
if(NOT idir STREQUAL "-") # filter out "-I-"
list(APPEND rv "${idir}")
endif()
endforeach()
@@ -71,8 +71,8 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
endif()
# SunPro compiler
if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "SunPro" AND
("${line}" MATCHES "-D__SUNPRO_C" OR "${line}" MATCHES "-D__SUNPRO_F") )
if(CMAKE_${lang}_COMPILER_ID STREQUAL "SunPro" AND
(line MATCHES "-D__SUNPRO_C" OR line MATCHES "-D__SUNPRO_F"))
string(REGEX MATCHALL " (-I ?)([^ ]*)" incs "${line}")
foreach(inc IN LISTS incs)
string(REGEX REPLACE " (-I ?)([^ ]*)" "\\2" idir "${inc}")
@@ -81,7 +81,7 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
endif()
endforeach()
if(rv)
if ("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "CXX")
if (lang STREQUAL "C" OR lang STREQUAL "CXX")
# /usr/include appears to be hardwired in
list(APPEND rv "/usr/include")
endif()
@@ -92,24 +92,24 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
endif()
# XL compiler
if(("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XL"
OR "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XLClang")
AND "${line}" MATCHES "^/"
AND ( ("${lang}" STREQUAL "Fortran" AND
"${line}" MATCHES "/xl[fF]entry " AND
"${line}" MATCHES "OSVAR\\([^ ]+\\)")
if((CMAKE_${lang}_COMPILER_ID STREQUAL "XL"
OR CMAKE_${lang}_COMPILER_ID STREQUAL "XLClang")
AND line MATCHES "^/"
AND ( (lang STREQUAL "Fortran" AND
line MATCHES "/xl[fF]entry " AND
line MATCHES "OSVAR\\([^ ]+\\)")
OR
( ("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "CXX") AND
"${line}" MATCHES "/xl[cC]2?entry " AND
"${line}" MATCHES " -qosvar=")
( (lang STREQUAL "C" OR lang STREQUAL "CXX") AND
line MATCHES "/xl[cC]2?entry " AND
line MATCHES " -qosvar=")
) )
# -qnostdinc cancels other stdinc flags, even if present
string(FIND "${line}" " -qnostdinc" nostd)
if(NOT ${nostd} EQUAL -1)
if(NOT nostd EQUAL -1)
set(rv "") # defined but empty
string(APPEND log " got implicit includes via XL parser (nostdinc)\n")
else()
if("${lang}" STREQUAL "CXX")
if(lang STREQUAL "CXX")
string(REGEX MATCHALL " -qcpp_stdinc=([^ ]*)" std "${line}")
string(REGEX MATCHALL " -qgcc_cpp_stdinc=([^ ]*)" gcc_std "${line}")
else()