Skip to content

Commit b239891

Browse files
[SYCL RTC] Correctly handle /MT//MD on Windows (#20027)
We use `/MT` downstream where #19924 has caused some issues. This fixes that. --------- Co-authored-by: Jinsong Ji <[email protected]>
1 parent 51add22 commit b239891

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sycl-jit/jit-compiler/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ add_custom_command(
3636
if (WIN32)
3737
set(clang_exe ${CMAKE_BINARY_DIR}/bin/clang-cl.exe)
3838
set(SYCL_JIT_RESOURCE_CXX_FLAGS /O2 /std:c++17 /W0)
39-
if (CMAKE_BUILD_TYPE MATCHES "Debug")
40-
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS /MDd)
41-
else()
42-
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS /MD)
39+
40+
# Determine if we should use static (/MT) or dynamic (/MD) runtime
41+
set(USE_STATIC_RUNTIME 0)
42+
if(CMAKE_MSVC_RUNTIME_LIBRARY AND NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL")
43+
set(USE_STATIC_RUNTIME 1)
4344
endif()
45+
46+
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS /M$<IF:${USE_STATIC_RUNTIME},T,D>$<$<CONFIG:Debug>:d>)
4447
else()
4548
get_host_tool_path( clang CLANG clang_exe clang_target )
4649
set(SYCL_JIT_RESOURCE_CXX_FLAGS -O2 -Wno-c23-extensions -std=c++17 -fPIC -fvisibility=hidden)

0 commit comments

Comments
 (0)