From 9339e374200fdf0e9884f600ff8c92335bdd51c9 Mon Sep 17 00:00:00 2001 From: Gergely Meszaros Date: Fri, 8 Nov 2024 05:14:28 -0800 Subject: [PATCH] Wrap linker flags on Windows for IntelLLLVM The Intel C++ compiler requires linker flags to be wrapped, because CMake passes them through the compiler driver. Prefix linker options with `LINKER:`. CMake will transorm it to the appropriate flag for the compiler driver: (Nothing for MSVC or clang-cl, and /Qoption,link for icx), so this will work for other compilers and for earlier CMake versions too. Signed-off-by: Gergely Meszaros --- cmake/helpers.cmake | 10 +++++----- source/adapters/CMakeLists.txt | 2 +- source/adapters/level_zero/CMakeLists.txt | 4 ++-- source/loader/CMakeLists.txt | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index a6e3a344a4..41b7171fc4 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -131,9 +131,9 @@ function(add_ur_target_link_options name) endif() elseif(MSVC) target_link_options(${name} PRIVATE - /DYNAMICBASE - /HIGHENTROPYVA - /NXCOMPAT + LINKER:/DYNAMICBASE + LINKER:/HIGHENTROPYVA + LINKER:/NXCOMPAT ) endif() endfunction() @@ -141,7 +141,7 @@ endfunction() function(add_ur_target_exec_options name) if(MSVC) target_link_options(${name} PRIVATE - /ALLOWISOLATION + LINKER:/ALLOWISOLATION ) endif() endfunction() @@ -159,7 +159,7 @@ function(add_ur_library name) add_ur_target_link_options(${name}) if(MSVC) target_link_options(${name} PRIVATE - $<$,link.exe>:/DEPENDENTLOADFLAG:0x2000> + $<$,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000> ) endif() endfunction() diff --git a/source/adapters/CMakeLists.txt b/source/adapters/CMakeLists.txt index f981c17dd5..66cd8b7648 100644 --- a/source/adapters/CMakeLists.txt +++ b/source/adapters/CMakeLists.txt @@ -13,7 +13,7 @@ function(add_ur_adapter name) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../adapter.def.in ${ADAPTER_VERSION_SCRIPT} @ONLY) set_target_properties(${name} PROPERTIES - LINK_FLAGS "/DEF:${ADAPTER_VERSION_SCRIPT}" + LINK_OPTIONS "LINKER:/DEF:${ADAPTER_VERSION_SCRIPT}" ) elseif(APPLE) target_compile_options(${name} PRIVATE "-fvisibility=hidden") diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index d700fbb2c3..6465ebaa51 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -100,7 +100,7 @@ if(UR_BUILD_ADAPTER_L0) if (WIN32) # 0x800: Search for the DLL only in the System32 folder - target_link_options(ur_adapter_level_zero PRIVATE /DEPENDENTLOADFLAG:0x800) + target_link_options(ur_adapter_level_zero PRIVATE LINKER:/DEPENDENTLOADFLAG:0x800) endif() target_link_libraries(ur_adapter_level_zero PRIVATE @@ -194,7 +194,7 @@ if(UR_BUILD_ADAPTER_L0_V2) if (WIN32) # 0x800: Search for the DLL only in the System32 folder - target_link_options(ur_adapter_level_zero_v2 PUBLIC /DEPENDENTLOADFLAG:0x800) + target_link_options(ur_adapter_level_zero_v2 PUBLIC LINKER:/DEPENDENTLOADFLAG:0x800) endif() target_link_libraries(ur_adapter_level_zero_v2 PRIVATE diff --git a/source/loader/CMakeLists.txt b/source/loader/CMakeLists.txt index 07dab17943..b740411c61 100644 --- a/source/loader/CMakeLists.txt +++ b/source/loader/CMakeLists.txt @@ -28,7 +28,7 @@ if (MSVC) set(LOADER_VERSION_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/ur_loader.def) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader.def.in ${LOADER_VERSION_SCRIPT} @ONLY) set_target_properties(ur_loader PROPERTIES - LINK_FLAGS "/DEF:${LOADER_VERSION_SCRIPT}" + LINK_OPTIONS "LINKER:/DEF:${LOADER_VERSION_SCRIPT}" ) elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(TARGET_LIBNAME libur_loader_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})