summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChuck Cranor <chuck@ece.cmu.edu>2019-01-25 17:57:42 (GMT)
committerChuck Cranor <chuck@ece.cmu.edu>2019-01-25 17:57:42 (GMT)
commit2e91627dea507ec6f4406d561b073bdc14860cb1 (patch)
treee3cb2c95856f48dba30b3dfdd22bc0bbfebd3c21 /Modules
parent568343767e5852f0e5751341a3aa44ab6feffb8a (diff)
downloadCMake-2e91627dea507ec6f4406d561b073bdc14860cb1.zip
CMake-2e91627dea507ec6f4406d561b073bdc14860cb1.tar.gz
CMake-2e91627dea507ec6f4406d561b073bdc14860cb1.tar.bz2
ParseImplicitIncludeInfo: add Fortran implicit include handling
Currently cmake is only setting CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES the first time it runs (the implicit includes parser is only run when the cache variables are initially populated). It is left unset during additional runs. This behavior is both confusing and inconsistent. Modify CMakeFortranCompiler.cmake.in to preserve the value of CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES so that cmake's Fortran behavior matches C and CXX (i.e. CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES retains its value across runs). The implicit includes variable may not be as useful for Fortran as it is for C and CXX, but we do want cmake to be consistent in how it is handled. Adjust CMakeParseImplicitIncludeInfo to parse verbose Fortran output for Cray and XL compiler IDs (GNU and clang were already ok since they use the same verbose output format as they do with C/CXX). Allow Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt to generate test inputs for Fortran too, and add some sample Fortran input files for the Tests/RunCMake/ParseImplicitIncludeInfo test.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeFortranCompiler.cmake.in1
-rw-r--r--Modules/CMakeParseImplicitIncludeInfo.cmake18
2 files changed, 13 insertions, 6 deletions
diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in
index 9b951fc..ae7b73a 100644
--- a/Modules/CMakeFortranCompiler.cmake.in
+++ b/Modules/CMakeFortranCompiler.cmake.in
@@ -61,6 +61,7 @@ endif()
@CMAKE_Fortran_SYSROOT_FLAG_CODE@
@CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
+set(CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "@CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake
index 6603e1c..211406d 100644
--- a/Modules/CMakeParseImplicitIncludeInfo.cmake
+++ b/Modules/CMakeParseImplicitIncludeInfo.cmake
@@ -13,8 +13,8 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
# Cray compiler (from cray wrapper, via PrgEnv-cray)
if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "Cray" AND
- "${line}" MATCHES "^/" AND "${line}" MATCHES "/ccfe " AND
- "${line}" MATCHES "-isystem")
+ "${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}")
@@ -46,10 +46,16 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
endif()
endif()
- # XL C/CXX compiler
- if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XL" AND
- "${line}" MATCHES "^/" AND "${line}" MATCHES "/xlcentry |/xlCentry " AND
- "${line}" MATCHES " -qosvar=")
+ # XL compiler
+ if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XL" 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]entry " AND
+ "${line}" MATCHES " -qosvar=")
+ ) )
# -qnostdinc cancels other stdinc flags, even if present
string(FIND "${line}" " -qnostdinc" nostd)
if(NOT ${nostd} EQUAL -1)