summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-04-03 13:35:09 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-04-03 13:35:19 (GMT)
commita045c5c4ecabaa7f490c601a15a966c9fa865283 (patch)
tree5e510e12d1729e120127dac40a2a8c0ad1e33050 /Modules/Platform
parent85f8094cb6ecf9550a21208f2fe9e3f5ef32de26 (diff)
parent3f5cd0389f1896027bb5ca9de0c737ff6407bc87 (diff)
downloadCMake-a045c5c4ecabaa7f490c601a15a966c9fa865283.zip
CMake-a045c5c4ecabaa7f490c601a15a966c9fa865283.tar.gz
CMake-a045c5c4ecabaa7f490c601a15a966c9fa865283.tar.bz2
Merge topic 'vs-intel-oneapi' into release-3.29
3f5cd0389f IntelLLVM: Fix link flags with Visual Studio generators Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9398
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Windows-IntelLLVM.cmake35
-rw-r--r--Modules/Platform/Windows-MSVC.cmake44
2 files changed, 34 insertions, 45 deletions
diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake
index eac3f0a..b1a336b 100644
--- a/Modules/Platform/Windows-IntelLLVM.cmake
+++ b/Modules/Platform/Windows-IntelLLVM.cmake
@@ -8,30 +8,19 @@ if(__WINDOWS_INTEL_LLVM)
endif()
set(__WINDOWS_INTEL_LLVM 1)
-# Platform/Windows-MSVC adds some linking options icx/ifx do not understand,
-# but that need to be passed to the linker. Wrap all the linking options from
-# Platform/Windows-MSVC so that the compiler will hand them off to the linker
-# without interpreting them.
-
-# Save original CMAKE_${t}_LINKER_FLAGS_INIT
-foreach(t EXE SHARED MODULE STATIC)
- set(_saved_cmake_${t}_linker_flags_init ${CMAKE_${t}_LINKER_FLAGS_INIT})
- set(CMAKE_${t}_LINKER_FLAGS_INIT "")
-endforeach()
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ # MSBuild invokes the "link" tool directly.
+ set(_IntelLLVM_LINKER_WRAPPER_FLAG "")
+ set(_IntelLLVM_LINKER_WRAPPER_FLAG_SEP "")
+else()
+ # Our rules below drive linking through the compiler front-end.
+ # Wrap flags meant for the linker.
+ set(_IntelLLVM_LINKER_WRAPPER_FLAG "/Qoption,link,")
+ set(_IntelLLVM_LINKER_WRAPPER_FLAG_SEP ",")
+endif()
+set(_Wl "${_IntelLLVM_LINKER_WRAPPER_FLAG}")
include(Platform/Windows-MSVC)
-# Wrap linker flags from Windows-MSVC
-set(_IntelLLVM_LINKER_WRAPPER_FLAG "/Qoption,link,")
-set(_IntelLLVM_LINKER_WRAPPER_FLAG_SEP ",")
-foreach(t EXE SHARED MODULE STATIC)
- set(_wrapped_linker_flags "")
- foreach(flag ${CMAKE_${t}_LINKER_FLAGS_INIT})
- string(STRIP ${flag} flag)
- list(APPEND _wrapped_linker_flags "${_IntelLLVM_LINKER_WRAPPER_FLAG}${flag}")
- endforeach()
- set(CMAKE_${t}_LINKER_FLAGS_INIT "")
- list(APPEND CMAKE_${t}_LINKER_FLAGS_INIT
- ${_saved_cmake_${t}_linker_flags_init} ${_wrapped_linker_flags})
-endforeach()
+unset(_Wl)
macro(__windows_compiler_intel lang)
__windows_compiler_msvc(${lang})
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index 48e7c4e..ef57031 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -206,7 +206,7 @@ if(WINCE)
set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib")
foreach(t EXE SHARED MODULE)
- string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_Wl}/NODEFAULTLIB:libc.lib ${_Wl}/NODEFAULTLIB:oldnames.lib")
endforeach()
if (MSVC_VERSION LESS 1600)
@@ -230,7 +230,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsKernelModeDriver")
set(_FLAGS_C " -kernel")
set(_FLAGS_CXX " -kernel")
foreach(t EXE SHARED MODULE)
- string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " -NODEFAULTLIB")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_Wl}-NODEFAULTLIB")
endforeach()
if((_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "x64") OR (_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "x64"))
set(_PLATFORM_DEFINES "${_PLATFORM_DEFINES} -D_AMD64_ -DAMD64")
@@ -279,30 +279,30 @@ set (CMAKE_LINK_DEF_FILE_FLAG "/DEF:")
# set the machine type
if(MSVC_C_ARCHITECTURE_ID)
if(MSVC_C_ARCHITECTURE_ID MATCHES "^ARMV.I")
- set(_MACHINE_ARCH_FLAG "/machine:THUMB")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:THUMB")
elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64")
- set(_MACHINE_ARCH_FLAG "/machine:ARM64")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:ARM64")
elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64EC")
- set(_MACHINE_ARCH_FLAG "/machine:ARM64EC")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:ARM64EC")
elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM")
- set(_MACHINE_ARCH_FLAG "/machine:ARM")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:ARM")
else()
- set(_MACHINE_ARCH_FLAG "/machine:${MSVC_C_ARCHITECTURE_ID}")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:${MSVC_C_ARCHITECTURE_ID}")
endif()
elseif(MSVC_CXX_ARCHITECTURE_ID)
if(MSVC_CXX_ARCHITECTURE_ID MATCHES "^ARMV.I")
- set(_MACHINE_ARCH_FLAG "/machine:THUMB")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:THUMB")
elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64")
- set(_MACHINE_ARCH_FLAG "/machine:ARM64")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:ARM64")
elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64EC")
- set(_MACHINE_ARCH_FLAG "/machine:ARM64EC")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:ARM64EC")
elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
- set(_MACHINE_ARCH_FLAG "/machine:ARM")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:ARM")
else()
- set(_MACHINE_ARCH_FLAG "/machine:${MSVC_CXX_ARCHITECTURE_ID}")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:${MSVC_CXX_ARCHITECTURE_ID}")
endif()
elseif(MSVC_Fortran_ARCHITECTURE_ID)
- set(_MACHINE_ARCH_FLAG "/machine:${MSVC_Fortran_ARCHITECTURE_ID}")
+ set(_MACHINE_ARCH_FLAG "${_Wl}/machine:${MSVC_Fortran_ARCHITECTURE_ID}")
endif()
# add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtype
@@ -310,28 +310,28 @@ endif()
set( MSVC_INCREMENTAL_YES_FLAG "")
if(NOT WINDOWS_PHONE AND NOT WINDOWS_STORE AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsKernelModeDriver")
if(NOT MSVC_INCREMENTAL_DEFAULT)
- set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:YES")
+ set(MSVC_INCREMENTAL_YES_FLAG "${_Wl}/INCREMENTAL:YES")
else()
- set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL" )
+ set(MSVC_INCREMENTAL_YES_FLAG "${_Wl}/INCREMENTAL" )
endif()
endif()
foreach(t EXE SHARED MODULE)
string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}")
if (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
- string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " /debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
- string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " /debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " ${_Wl}/debug ${_Wl}/pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " ${_Wl}/debug ${_Wl}/pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
else ()
- string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " /debug ${MSVC_INCREMENTAL_YES_FLAG}")
- string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " /debug ${MSVC_INCREMENTAL_YES_FLAG}")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " ${_Wl}/debug ${MSVC_INCREMENTAL_YES_FLAG}")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " ${_Wl}/debug ${MSVC_INCREMENTAL_YES_FLAG}")
endif ()
# for release and minsize release default to no incremental linking
- string(APPEND CMAKE_${t}_LINKER_FLAGS_MINSIZEREL_INIT " /INCREMENTAL:NO")
- string(APPEND CMAKE_${t}_LINKER_FLAGS_RELEASE_INIT " /INCREMENTAL:NO")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_MINSIZEREL_INIT " ${_Wl}/INCREMENTAL:NO")
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_RELEASE_INIT " ${_Wl}/INCREMENTAL:NO")
endforeach()
if((_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64EC") OR (_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64EC"))
- string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " /machine:ARM64X")
+ string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " ${_Wl}/machine:ARM64X")
else()
string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}")
endif()