From 70f6c093c70d7be1e0da66be603e680566d73186 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 23 Oct 2024 17:39:01 +0100 Subject: [PATCH] Make /DEPENDENTLOADFLAG value configurable In Windows development environments the default value of `0x2000` is too restrictive as it does not allow loading the `OpenCL.dll` built as part of the project. This patch makes the value passed to the `/DEPENDENTLOADFLAG` option configurable using the `UR_DEPENDENTLOADFLAG` CMake option. --- unified-runtime/CMakeLists.txt | 4 ++++ unified-runtime/cmake/helpers.cmake | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/unified-runtime/CMakeLists.txt b/unified-runtime/CMakeLists.txt index 311c9c487a6a9..827cb7125d1d3 100644 --- a/unified-runtime/CMakeLists.txt +++ b/unified-runtime/CMakeLists.txt @@ -67,6 +67,10 @@ set(UR_ADAPTER_HIP_SOURCE_DIR "" CACHE PATH "Path to external 'hip' adapter source dir") set(UR_ADAPTER_NATIVE_CPU_SOURCE_DIR "" CACHE PATH "Path to external 'native_cpu' adapter source dir") +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + set(UR_DEPENDENTLOADFLAG "0x2000" CACHE STRING + "Value to use for Windows link.exe /DEPENDENTLOADFLAG option") +endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(helpers) diff --git a/unified-runtime/cmake/helpers.cmake b/unified-runtime/cmake/helpers.cmake index 1f5bd91d93219..14357005e4cc9 100644 --- a/unified-runtime/cmake/helpers.cmake +++ b/unified-runtime/cmake/helpers.cmake @@ -194,9 +194,9 @@ function(add_ur_library name) add_library(${name} ${ARGN}) add_ur_target_compile_options(${name}) add_ur_target_link_options(${name}) - if(MSVC) + if(CMAKE_LINKER MATCHES link.exe) target_link_options(${name} PRIVATE - $<$,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000> + LINKER:/DEPENDENTLOADFLAG:${UR_DEPENDENTLOADFLAG} ) endif() endfunction()