Skip to content

Commit af9bb26

Browse files
committed
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 <[email protected]>
1 parent d8cc532 commit af9bb26

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

cmake/helpers.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,17 @@ function(add_ur_target_link_options name)
130130
endif()
131131
elseif(MSVC)
132132
target_link_options(${name} PRIVATE
133-
/DYNAMICBASE
134-
/HIGHENTROPYVA
135-
/NXCOMPAT
133+
LINKER:/DYNAMICBASE
134+
LINKER:/HIGHENTROPYVA
135+
LINKER:/NXCOMPAT
136136
)
137137
endif()
138138
endfunction()
139139

140140
function(add_ur_target_exec_options name)
141141
if(MSVC)
142142
target_link_options(${name} PRIVATE
143-
/ALLOWISOLATION
143+
LINKER:/ALLOWISOLATION
144144
)
145145
endif()
146146
endfunction()
@@ -158,7 +158,7 @@ function(add_ur_library name)
158158
add_ur_target_link_options(${name})
159159
if(MSVC)
160160
target_link_options(${name} PRIVATE
161-
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:/DEPENDENTLOADFLAG:0x2000>
161+
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000>
162162
)
163163
endif()
164164
endfunction()

source/adapters/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function(add_ur_adapter name)
1313

1414
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../adapter.def.in ${ADAPTER_VERSION_SCRIPT} @ONLY)
1515
set_target_properties(${name} PROPERTIES
16-
LINK_FLAGS "/DEF:${ADAPTER_VERSION_SCRIPT}"
16+
LINK_OPTIONS "LINKER:/DEF:${ADAPTER_VERSION_SCRIPT}"
1717
)
1818
elseif(APPLE)
1919
target_compile_options(${name} PRIVATE "-fvisibility=hidden")

source/adapters/level_zero/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ if(UR_BUILD_ADAPTER_L0)
100100

101101
if (WIN32)
102102
# 0x800: Search for the DLL only in the System32 folder
103-
target_link_options(ur_adapter_level_zero PRIVATE /DEPENDENTLOADFLAG:0x800)
103+
target_link_options(ur_adapter_level_zero PRIVATE LINKER:/DEPENDENTLOADFLAG:0x800)
104104
endif()
105105

106106
target_link_libraries(ur_adapter_level_zero PRIVATE
@@ -193,7 +193,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
193193

194194
if (WIN32)
195195
# 0x800: Search for the DLL only in the System32 folder
196-
target_link_options(ur_adapter_level_zero_v2 PUBLIC /DEPENDENTLOADFLAG:0x800)
196+
target_link_options(ur_adapter_level_zero_v2 PUBLIC LINKER:/DEPENDENTLOADFLAG:0x800)
197197
endif()
198198

199199
target_link_libraries(ur_adapter_level_zero_v2 PRIVATE

source/loader/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (MSVC)
2828
set(LOADER_VERSION_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/ur_loader.def)
2929
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader.def.in ${LOADER_VERSION_SCRIPT} @ONLY)
3030
set_target_properties(ur_loader PROPERTIES
31-
LINK_FLAGS "/DEF:${LOADER_VERSION_SCRIPT}"
31+
LINK_OPTIONS "LINKER:/DEF:${LOADER_VERSION_SCRIPT}"
3232
)
3333
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
3434
set(TARGET_LIBNAME libur_loader_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})

0 commit comments

Comments
 (0)