summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2021-03-13 13:37:19 (GMT)
committerRaul Tambre <raul@tambre.ee>2021-03-17 15:51:56 (GMT)
commit56c759b000ab5041aff9a92d51a6cc471e7d34a4 (patch)
treec8b181920834eaa63970012a4f0bd848d11078ff /Modules/Platform
parent982f7bb5063453d3c0be102c917bb660ec21978b (diff)
downloadCMake-56c759b000ab5041aff9a92d51a6cc471e7d34a4.zip
CMake-56c759b000ab5041aff9a92d51a6cc471e7d34a4.tar.gz
CMake-56c759b000ab5041aff9a92d51a6cc471e7d34a4.tar.bz2
Per-language Win32/Console flags
Allows using different compilers with different flags for different languages. For example Clang with GNU-like commandline for CXX and MSVC as host compiler for CUDA. Should help with #21914.
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/CYGWIN-GNU.cmake2
-rw-r--r--Modules/Platform/Windows-Clang.cmake4
-rw-r--r--Modules/Platform/Windows-Embarcadero.cmake8
-rw-r--r--Modules/Platform/Windows-GNU.cmake2
-rw-r--r--Modules/Platform/Windows-MSVC.cmake12
-rw-r--r--Modules/Platform/Windows-OpenWatcom-C.cmake1
-rw-r--r--Modules/Platform/Windows-OpenWatcom-CXX.cmake1
-rw-r--r--Modules/Platform/Windows-OpenWatcom.cmake7
-rw-r--r--Modules/Platform/Windows-df.cmake4
9 files changed, 24 insertions, 17 deletions
diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake
index 4fa14ce..b81bd4d 100644
--- a/Modules/Platform/CYGWIN-GNU.cmake
+++ b/Modules/Platform/CYGWIN-GNU.cmake
@@ -10,7 +10,6 @@ set(__CYGWIN_COMPILER_GNU 1)
# TODO: Is -Wl,--enable-auto-import now always default?
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,--enable-auto-import")
-set(CMAKE_CREATE_WIN32_EXE "-mwindows")
set(CMAKE_GNULD_IMAGE_VERSION
"-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
@@ -23,6 +22,7 @@ macro(__cygwin_compiler_gnu lang)
"<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_${lang}_LINK_EXECUTABLE
"<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
+ set(CMAKE_${lang}_CREATE_WIN32_EXE "-mwindows")
# No -fPIC on cygwin
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake
index c508ac1..7365ff5 100644
--- a/Modules/Platform/Windows-Clang.cmake
+++ b/Modules/Platform/Windows-Clang.cmake
@@ -71,8 +71,8 @@ macro(__windows_compiler_clang_gnu lang)
set(CMAKE_${lang}_LINK_EXECUTABLE
"<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
- set(CMAKE_CREATE_WIN32_EXE "-Xlinker /subsystem:windows")
- set(CMAKE_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console")
+ set(CMAKE_${lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows")
+ set(CMAKE_${lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console")
if(NOT "${lang}" STREQUAL "ASM")
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt)
diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake
index 8f1d024..4ecc2c2 100644
--- a/Modules/Platform/Windows-Embarcadero.cmake
+++ b/Modules/Platform/Windows-Embarcadero.cmake
@@ -51,11 +51,6 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib")
# Borland cannot handle + in the file name, so mangle object file name
set (CMAKE_MANGLE_OBJECT_FILE_NAMES "ON")
-# extra flags for a win32 exe
-set(CMAKE_CREATE_WIN32_EXE "${_tW}" )
-# extra flags for a console app
-set(CMAKE_CREATE_CONSOLE_EXE "${_tC}" )
-
set (CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.")
@@ -124,6 +119,9 @@ macro(__embarcadero_language lang)
"tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}"
)
+ set(CMAKE_${lang}_CREATE_WIN32_EXE "${_tW}")
+ set(CMAKE_${lang}_CREATE_CONSOLE_EXE "${_tC}")
+
# Precompile Headers
if (EMBARCADERO)
set(CMAKE_PCH_EXTENSION .pch)
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index a2e3811..e50c215 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -35,7 +35,6 @@ set(CMAKE_LIBRARY_PATH_FLAG "-L")
set(CMAKE_LINK_LIBRARY_FLAG "-l")
set(CMAKE_LINK_DEF_FILE_FLAG "") # Empty string: passing the file is enough
set(CMAKE_LINK_LIBRARY_SUFFIX "")
-set(CMAKE_CREATE_WIN32_EXE "-mwindows")
set(CMAKE_GNULD_IMAGE_VERSION
"-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
@@ -105,6 +104,7 @@ macro(__windows_compiler_gnu lang)
"<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_${lang}_LINK_EXECUTABLE
"<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
+ set(CMAKE_${lang}_CREATE_WIN32_EXE "-mwindows")
list(APPEND CMAKE_${lang}_ABI_FILES "Platform/Windows-GNU-${lang}-ABI")
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index e384af4..4223bde 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -27,12 +27,8 @@ else()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsCE")
- set(CMAKE_CREATE_WIN32_EXE "/entry:WinMainCRTStartup")
- set(CMAKE_CREATE_CONSOLE_EXE "/entry:mainACRTStartup")
set(_PLATFORM_LINK_FLAGS " /subsystem:windowsce")
else()
- set(CMAKE_CREATE_WIN32_EXE "/subsystem:windows")
- set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:console")
set(_PLATFORM_LINK_FLAGS "")
endif()
@@ -351,6 +347,14 @@ macro(__windows_compiler_msvc lang)
set(CMAKE_${lang}_LINK_EXECUTABLE
"${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
+ if(CMAKE_SYSTEM_NAME STREQUAL "WindowsCE")
+ set(CMAKE_${lang}_CREATE_WIN32_EXE "/entry:WinMainCRTStartup")
+ set(CMAKE_${lang}_CREATE_CONSOLE_EXE "/entry:mainACRTStartup")
+ else()
+ set(CMAKE_${lang}_CREATE_WIN32_EXE "/subsystem:windows")
+ set(CMAKE_${lang}_CREATE_CONSOLE_EXE "/subsystem:console")
+ endif()
+
set(CMAKE_PCH_EXTENSION .pch)
set(CMAKE_LINK_PCH ON)
if (CMAKE_${lang}_COMPILER_ID STREQUAL "Clang")
diff --git a/Modules/Platform/Windows-OpenWatcom-C.cmake b/Modules/Platform/Windows-OpenWatcom-C.cmake
index ce9bc45..b82a4cb 100644
--- a/Modules/Platform/Windows-OpenWatcom-C.cmake
+++ b/Modules/Platform/Windows-OpenWatcom-C.cmake
@@ -1 +1,2 @@
include(Platform/Windows-OpenWatcom)
+__windows_open_watcom(C)
diff --git a/Modules/Platform/Windows-OpenWatcom-CXX.cmake b/Modules/Platform/Windows-OpenWatcom-CXX.cmake
index ce9bc45..ac90d28 100644
--- a/Modules/Platform/Windows-OpenWatcom-CXX.cmake
+++ b/Modules/Platform/Windows-OpenWatcom-CXX.cmake
@@ -1 +1,2 @@
include(Platform/Windows-OpenWatcom)
+__windows_open_watcom(CXX)
diff --git a/Modules/Platform/Windows-OpenWatcom.cmake b/Modules/Platform/Windows-OpenWatcom.cmake
index 70055da..19bcb97 100644
--- a/Modules/Platform/Windows-OpenWatcom.cmake
+++ b/Modules/Platform/Windows-OpenWatcom.cmake
@@ -6,8 +6,6 @@ include_guard()
set(CMAKE_BUILD_TYPE_INIT Debug)
-set(CMAKE_CREATE_WIN32_EXE "system nt_win" )
-set(CMAKE_CREATE_CONSOLE_EXE "system nt" )
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " system nt_dll")
string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system nt_dll")
@@ -30,3 +28,8 @@ if(CMAKE_CROSSCOMPILING)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES $ENV{WATCOM}/h $ENV{WATCOM}/h/nt)
endif()
endif()
+
+macro(__windows_open_watcom lang)
+ set(CMAKE_${lang}_CREATE_WIN32_EXE "system nt_win")
+ set(CMAKE_${lang}_CREATE_CONSOLE_EXE "system nt")
+endmacro()
diff --git a/Modules/Platform/Windows-df.cmake b/Modules/Platform/Windows-df.cmake
index 8b824bc..c823423 100644
--- a/Modules/Platform/Windows-df.cmake
+++ b/Modules/Platform/Windows-df.cmake
@@ -27,8 +27,8 @@ set(CMAKE_Fortran_COMPILE_OBJECT
set(CMAKE_Fortran_LINK_EXECUTABLE
"<CMAKE_Fortran_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> /exe:<TARGET> <OBJECTS> /link <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
-set(CMAKE_CREATE_WIN32_EXE /winapp)
-set(CMAKE_CREATE_CONSOLE_EXE )
+set(CMAKE_Fortran_CREATE_WIN32_EXE /winapp)
+set(CMAKE_Fortran_CREATE_CONSOLE_EXE )
# does the compiler support pdbtype and is it the newer compiler