diff options
author | Brad King <brad.king@kitware.com> | 2017-05-22 14:37:22 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-05-22 14:37:57 (GMT) |
commit | c9d9a3fb39ff36dd2818238916697f685b6ccea7 (patch) | |
tree | 51581b26c4e166192b5491491cbefb035a4f7aa0 /Modules | |
parent | a152e97e2354a0396ab8f8433d61e8f8da7da7f5 (diff) | |
parent | 4eb15824b3092866f9c30d7af3221487c60fab07 (diff) | |
download | CMake-c9d9a3fb39ff36dd2818238916697f685b6ccea7.zip CMake-c9d9a3fb39ff36dd2818238916697f685b6ccea7.tar.gz CMake-c9d9a3fb39ff36dd2818238916697f685b6ccea7.tar.bz2 |
Merge topic 'pgi-fix-windows'
4eb15824 Windows-PGI: Add platform definitions
a94ae96e Windows-PGI: Adapt default compiler flags
c2c2d366 ImplicitLinkInfo: Add support for PGI on Windows
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !794
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 4 | ||||
-rw-r--r-- | Modules/CMakeParseImplicitLinkInfo.cmake | 17 | ||||
-rw-r--r-- | Modules/Compiler/PGI.cmake | 10 | ||||
-rw-r--r-- | Modules/Platform/Windows-PGI-C.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-PGI-Fortran.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-PGI.cmake | 48 |
6 files changed, 78 insertions, 5 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 4c0486e..e4103d0 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -26,6 +26,10 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC" + OR (CMAKE_HOST_WIN32 AND ( + "x${CMAKE_C_COMPILER_ID}" STREQUAL "xPGI" + OR "x${CMAKE_Fortran_COMPILER_ID}" STREQUAL "xPGI" + )) OR (CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")) diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 1d0030c..3b77278 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -18,9 +18,13 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj get_filename_component(linker ${CMAKE_LINKER} NAME) string(REGEX REPLACE "([][+.*?()^$])" "\\\\\\1" linker "${linker}") endif() + set(startfile "CMAKE_LINK_STARTFILE-NOTFOUND") + if(CMAKE_LINK_STARTFILE) + set(startfile "${CMAKE_LINK_STARTFILE}") + endif() # Construct a regex to match linker lines. It must match both the # whole line and just the command (argv[0]). - set(linker_regex "^( *|.*[/\\])(${linker}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)") + set(linker_regex "^( *|.*[/\\])(${linker}|${startfile}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)") set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=|/ldfe ") string(APPEND log " link line regex: [${linker_regex}]\n") string(REGEX REPLACE "\r?\n" ";" output_lines "${text}") @@ -55,9 +59,9 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj string(REGEX REPLACE "^-L" "" dir "${arg}") list(APPEND implicit_dirs_tmp ${dir}) string(APPEND log " arg [${arg}] ==> dir [${dir}]\n") - elseif("${arg}" MATCHES "^[-/]LIBPATH:(.+)") + elseif("${arg}" MATCHES "^[-/](LIBPATH|libpath):(.+)") # MSVC search path. - set(dir "${CMAKE_MATCH_1}") + set(dir "${CMAKE_MATCH_2}") list(APPEND implicit_dirs_tmp ${dir}) string(APPEND log " arg [${arg}] ==> dir [${dir}]\n") elseif(is_msvc AND "${arg}" STREQUAL "-link") @@ -79,6 +83,11 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj # Unix library full path. list(APPEND implicit_libs_tmp ${arg}) string(APPEND log " arg [${arg}] ==> lib [${arg}]\n") + elseif("${arg}" MATCHES "^[-/](DEFAULTLIB|defaultlib):(.+)") + # Windows library. + set(lib "${CMAKE_MATCH_2}") + list(APPEND implicit_libs_tmp ${lib}) + string(APPEND log " arg [${arg}] ==> lib [${lib}]\n") elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.o$" AND obj_regex AND "${arg}" MATCHES "${obj_regex}") # Object file full path. @@ -133,7 +142,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj # We remove items that are not language-specific. set(implicit_libs "") foreach(lib IN LISTS implicit_libs_tmp) - if("x${lib}" MATCHES "^x(crt.*\\.o|System.*|.*libclang_rt.*)$") + if("x${lib}" MATCHES "^x(crt.*\\.o|System.*|.*libclang_rt.*|msvcrt.*|libvcruntime.*|libucrt.*|libcmt.*)$") string(APPEND log " remove lib [${lib}]\n") elseif(IS_ABSOLUTE "${lib}") get_filename_component(abs "${lib}" ABSOLUTE) diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake index bdabeba..0cbfd8a 100644 --- a/Modules/Compiler/PGI.cmake +++ b/Modules/Compiler/PGI.cmake @@ -18,9 +18,17 @@ macro(__compiler_pgi lang) string(APPEND CMAKE_${lang}_FLAGS_INIT " ") string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0") string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O2 -s") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -fast -O3 -Mipa=fast") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -fast -O3") + # -Mipa was dropped with PGI 16.3 from Windows versions + if(NOT CMAKE_HOST_WIN32 OR CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 16.3) + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Mipa=fast") + endif() string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -gopt") + if(CMAKE_HOST_WIN32) + string(APPEND CMAKE_${lang}_FLAGS_INIT " -Bdynamic") + endif() + # Preprocessing and assembly rules. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Platform/Windows-PGI-C.cmake b/Modules/Platform/Windows-PGI-C.cmake new file mode 100644 index 0000000..0495b93 --- /dev/null +++ b/Modules/Platform/Windows-PGI-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-PGI) +__windows_compiler_pgi(C) diff --git a/Modules/Platform/Windows-PGI-Fortran.cmake b/Modules/Platform/Windows-PGI-Fortran.cmake new file mode 100644 index 0000000..2222e33 --- /dev/null +++ b/Modules/Platform/Windows-PGI-Fortran.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-PGI) +__windows_compiler_pgi(Fortran) diff --git a/Modules/Platform/Windows-PGI.cmake b/Modules/Platform/Windows-PGI.cmake new file mode 100644 index 0000000..ad77e8a --- /dev/null +++ b/Modules/Platform/Windows-PGI.cmake @@ -0,0 +1,48 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__WINDOWS_COMPILER_PGI) + return() +endif() +set(__WINDOWS_COMPILER_PGI 1) + +# PGI on Windows doesn't support parallel compile processes +if(NOT DEFINED CMAKE_JOB_POOL_LINK OR NOT DEFINED CMAKE_JOB_POOL_COMPILE) + set(CMAKE_JOB_POOL_LINK PGITaskPool) + set(CMAKE_JOB_POOL_COMPILE PGITaskPool) + get_property(_pgijp GLOBAL PROPERTY JOB_POOLS) + if(NOT _pgijp MATCHES "PGITaskPool=") + set_property(GLOBAL APPEND PROPERTY JOB_POOLS PGITaskPool=1) + endif() + unset(_pgijp) +endif() + +set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1) +set(CMAKE_LINK_DEF_FILE_FLAG "-def:") +# The link flags for PGI are the raw filename to add a file +# and the UNIX -L syntax to link directories. +set(CMAKE_LINK_LIBRARY_FLAG "") +set(CMAKE_LINK_STARTFILE "pgimain[mx][xpt]+[.]obj") + +# Default to Debug builds, mirroring Windows-MSVC behavior +set(CMAKE_BUILD_TYPE_INIT Debug) + +if(CMAKE_VERBOSE_MAKEFILE) + set(CMAKE_CL_NOLOGO) +else() + set(CMAKE_CL_NOLOGO "/nologo") +endif() + +macro(__windows_compiler_pgi lang) + # Shared library compile and link rules. + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} -Mmakedll -implib:<TARGET_IMPLIB> -Xlinker -pdb:<TARGET_PDB> -Xlinker -version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + set(CMAKE_${lang}_CREATE_SHARED_MODULE "${CMAKE_${lang}_CREATE_SHARED_LIBRARY}") + set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} -implib:<TARGET_IMPLIB> -Xlinker -pdb:<TARGET_PDB> -Xlinker -version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + + if("${lang}" MATCHES "C|CXX") + set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib") + endif() +endmacro() |