Commit 0479ae49 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'implicit-incs-cleanup'

1293ed85 ParseImplicitIncludeInfo: keep implicit incl. consistent when rerunning cmake
eaf53158 CrayPrgEnv/ParseImplicitIncludes: simplify for new implict include parser
ef8f2376

 ParseImplicitIncludeInfo: add SunPro Fortran and PGI compiler, Cray fix
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2894
parents a906d7b4 1293ed85
......@@ -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 "")
......
......@@ -27,9 +27,52 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
endif()
endif()
# PGI compiler
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 ")
# cmdline has unparsed cmdline, remove it
string(REGEX REPLACE "-cmdline .*" "" line "${line}")
if("${line}" MATCHES " -nostdinc ")
set(rv "") # defined, but empty
else()
string(REGEX MATCHALL " -stdinc ([^ ]*)" incs "${line}")
foreach(inc IN LISTS incs)
string(REGEX REPLACE " -stdinc ([^ ]*)" "\\1" idir "${inc}")
string(REPLACE ":" ";" idir "${idir}")
list(APPEND rv ${idir})
endforeach()
endif()
if(DEFINED rv)
string(APPEND log " got implicit includes via PGI C/F parser!\n")
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")
# 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-"
list(APPEND rv "${idir}")
endif()
endforeach()
if(DEFINED rv)
string(APPEND log " got implicit includes via PGI CXX parser!\n")
else()
string(APPEND log " warning: PGI CXX parse failed!\n")
endif()
endif()
endif()
# SunPro compiler
if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "SunPro" AND
"${line}" MATCHES "-D__SUNPRO_C")
("${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}")
......@@ -38,8 +81,10 @@ 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")
# /usr/include appears to be hardwired in
list(APPEND rv "/usr/include")
endif()
string(APPEND log " got implicit includes via sunpro parser!\n")
else()
string(APPEND log " warning: sunpro parse failed!\n")
......
......@@ -8,13 +8,13 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform)
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu)
set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform)
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-h noc99,conform")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-h noc99,gnu")
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-h c99,conform")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-h c99,gnu")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5)
set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform)
set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-h std=c11,conform")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-h std=c11,gnu")
endif ()
endif ()
......
......@@ -2,21 +2,21 @@
# file Copyright.txt or https://cmake.org/licensing for details.
include(Compiler/Cray)
__compiler_cray(C)
__compiler_cray(CXX)
string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -h conform)
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -h gnu)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-h conform")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-h gnu")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11)
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-h std=c++11")
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-h std=c++11,gnu")
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14)
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-h std=c++14")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-h std=c++14,gnu")
endif ()
endif ()
......
......@@ -4,8 +4,4 @@ endif()
set(__craylinux_crayprgenv_c 1)
include(Compiler/CrayPrgEnv)
macro(__CrayPrgEnv_setup_C compiler_cmd link_cmd)
__CrayPrgEnv_setup(C
${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c
${compiler_cmd} ${link_cmd})
endmacro()
__CrayPrgEnv_setup(C)
......@@ -4,8 +4,4 @@ endif()
set(__craylinux_crayprgenv_cxx 1)
include(Compiler/CrayPrgEnv)
macro(__CrayPrgEnv_setup_CXX compiler_cmd link_cmd)
__CrayPrgEnv_setup(CXX
${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp
${compiler_cmd} ${link_cmd})
endmacro()
__CrayPrgEnv_setup(CXX)
if(__craylinux_crayprgenv_cray_c)
return()
endif()
set(__craylinux_crayprgenv_cray_c 1)
include(Compiler/CrayPrgEnv-C)
__CrayPrgEnv_setup_C("/opt/cray/cce/.*/ccfe" "/opt/cray/cce/.*/ld")
if(__craylinux_crayprgenv_cray_cxx)
return()
endif()
set(__craylinux_crayprgenv_cray_cxx 1)
include(Compiler/CrayPrgEnv-CXX)
__CrayPrgEnv_setup_CXX("/opt/cray/cce/.*/ccfe" "/opt/cray/cce/.*/ld")
if(__craylinux_crayprgenv_cray_fortran)
return()
endif()
set(__craylinux_crayprgenv_cray_fortran 1)
include(Compiler/CrayPrgEnv-Fortran)
__CrayPrgEnv_setup_Fortran("/opt/cray/cce/.*/ftnfe" "/opt/cray/cce/.*/ld")
......@@ -4,8 +4,4 @@ endif()
set(__craylinux_crayprgenv_fortran 1)
include(Compiler/CrayPrgEnv)
macro(__CrayPrgEnv_setup_Fortran compiler_cmd link_cmd)
__CrayPrgEnv_setup(Fortran
${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F
${compiler_cmd} ${link_cmd})
endmacro()
__CrayPrgEnv_setup(Fortran)
if(__craylinux_crayprgenv_gnu_c)
return()
endif()
set(__craylinux_crayprgenv_gnu_c 1)
include(Compiler/CrayPrgEnv-C)
__CrayPrgEnv_setup_C("/opt/gcc/.*/cc1" "/opt/gcc/.*/collect2")
if(__craylinux_crayprgenv_gnu_cxx)
return()
endif()
set(__craylinux_crayprgenv_gnu_cxx 1)
include(Compiler/CrayPrgEnv-CXX)
__CrayPrgEnv_setup_CXX("/opt/gcc/.*/cc1plus" "/opt/gcc/.*/collect2")
if(__craylinux_crayprgenv_gnu_fortran)
return()
endif()
set(__craylinux_crayprgenv_gnu_fortran 1)
include(Compiler/CrayPrgEnv-Fortran)
__CrayPrgEnv_setup_Fortran("/opt/gcc/.*/f951" "/opt/gcc/.*/collect2")
if(__craylinux_crayprgenv_intel_c)
return()
endif()
set(__craylinux_crayprgenv_intel_c 1)
include(Compiler/CrayPrgEnv-C)
__CrayPrgEnv_setup_C("/opt/intel/.*/mcpcom" "^ld ")
if(__craylinux_crayprgenv_intel_cxx)
return()
endif()
set(__craylinux_crayprgenv_intel_cxx 1)
include(Compiler/CrayPrgEnv-CXX)
__CrayPrgEnv_setup_CXX("/opt/intel/.*/mcpcom" "^ld ")
if(__craylinux_crayprgenv_intel_fortran)
return()
endif()
set(__craylinux_crayprgenv_intel_fortran 1)
include(Compiler/CrayPrgEnv-Fortran)
__CrayPrgEnv_setup_Fortran("/opt/intel/.*/fortcom" "^ld ")
if(__craylinux_crayprgenv_pgi_c)
return()
endif()
set(__craylinux_crayprgenv_pgi_c 1)
include(Compiler/CrayPrgEnv-C)
__CrayPrgEnv_setup_C("/opt/pgi/[^ ]*/pgc" "/usr/bin/ld")
if(__craylinux_crayprgenv_pgi_cxx)
return()
endif()
set(__craylinux_crayprgenv_pgi_cxx 1)
include(Compiler/CrayPrgEnv-CXX)
__CrayPrgEnv_setup_CXX("/opt/pgi/[^ ]*/pgcpp" "/usr/bin/ld")
if(__craylinux_crayprgenv_pgi_fortran)
return()
endif()
set(__craylinux_crayprgenv_pgi_fortran 1)
include(Compiler/CrayPrgEnv-Fortran)
__CrayPrgEnv_setup_Fortran("/opt/pgi/[^ ]*/pgf" "/usr/bin/ld")
......@@ -4,54 +4,7 @@ if(__craylinux_crayprgenv)
endif()
set(__craylinux_crayprgenv 1)
macro(__cray_extract_args cmd tag_regex out_var make_absolute)
string(REGEX MATCHALL "${tag_regex}" args "${cmd}")
foreach(arg IN LISTS args)
string(REGEX REPLACE "^${tag_regex}$" "\\2" param "${arg}")
if(make_absolute)
get_filename_component(param "${param}" ABSOLUTE)
endif()
list(APPEND ${out_var} ${param})
endforeach()
endmacro()
function(__cray_extract_implicit src compiler_cmd link_cmd lang include_dirs_var link_dirs_var link_libs_var)
set(BIN "${CMAKE_PLATFORM_INFO_DIR}/CrayExtractImplicit_${lang}.bin")
execute_process(
COMMAND ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_VERBOSE_FLAG} -o ${BIN}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error
)
if(EXISTS "${BIN}")
file(REMOVE "${BIN}")
endif()
set(include_dirs)
set(link_dirs)
set(link_libs)
string(REGEX REPLACE "\r?\n" ";" output_lines "${output}\n${error}")
foreach(line IN LISTS output_lines)
if("${line}" MATCHES "${compiler_cmd}")
__cray_extract_args("${line}" " -(I ?|isystem )([^ ]*)" include_dirs 1)
set(processed_include 1)
endif()
if("${line}" MATCHES "${link_cmd}")
__cray_extract_args("${line}" " -(L ?)([^ ]*)" link_dirs 1)
__cray_extract_args("${line}" " -(l ?)([^ ]*)" link_libs 0)
set(processed_link 1)
endif()
if(processed_include AND processed_link)
break()
endif()
endforeach()
set(${include_dirs_var} "${include_dirs}" PARENT_SCOPE)
set(${link_dirs_var} "${link_dirs}" PARENT_SCOPE)
set(${link_libs_var} "${link_libs}" PARENT_SCOPE)
set(CRAY_${lang}_EXTRACTED_IMPLICIT 1 CACHE INTERNAL "" FORCE)
endfunction()
macro(__CrayPrgEnv_setup lang test_src compiler_cmd link_cmd)
macro(__CrayPrgEnv_setup lang)
if(DEFINED ENV{CRAYPE_VERSION})
message(STATUS "Cray Programming Environment $ENV{CRAYPE_VERSION} ${lang}")
elseif(DEFINED ENV{ASYNCPE_VERSION})
......@@ -81,12 +34,4 @@ macro(__CrayPrgEnv_setup lang test_src compiler_cmd link_cmd)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(CMAKE_LINK_SEARCH_START_STATIC TRUE)
endif()
if(NOT CRAY_${lang}_EXTRACTED_IMPLICIT)
__cray_extract_implicit(
${test_src} ${compiler_cmd} ${link_cmd} ${lang}
CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES
CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES
CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES
)
endif()
endmacro()
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