Windows-PGI: Add platform definitions

PGI on Windows should use the Visual C++ linker and librarian and not
the ar provided for legacy reasons. The compiler parameters themselves
are the same as their Linux parameters and not compatible to MSVC
however.
This commit is contained in:
Christian Pfeiffer 2017-05-12 19:10:21 +02:00
parent a94ae96e6e
commit 4eb15824b3
4 changed files with 56 additions and 0 deletions

View File

@ -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"))

View File

@ -0,0 +1,2 @@
include(Platform/Windows-PGI)
__windows_compiler_pgi(C)

View File

@ -0,0 +1,2 @@
include(Platform/Windows-PGI)
__windows_compiler_pgi(Fortran)

View File

@ -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()