Skip to content

Commit

Permalink
if(MSVC)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen351 committed Mar 27, 2024
1 parent 4310f3a commit 0468a9d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,18 @@ target_include_directories(onnxruntime-genai PRIVATE ${ORT_HEADER_DIR})
target_include_directories(onnxruntime-genai-static PRIVATE ${ORT_HEADER_DIR})

if(MSVC)
target_compile_options(onnxruntime PRIVATE "/sdl" PRIVATE "/Qspectre")
check_cxx_compiler_flag(-sdl HAS_SDL)
check_cxx_compiler_flag(-Qspectre HAS_QSPECTRE)
if (HAS_SDL)
target_compile_options(onnxruntime-genai PRIVATE "/sdl")
endif ()
if (HAS_QSPECTRE)
target_compile_options(onnxruntime-genai PRIVATE "/Qspectre")
endif ()
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
target_compile_options(onnxruntime PRIVATE "/CETCOMPAT")
endif()
endif()
target_compile_options(onnxruntime-genai PRIVATE "/CETCOMPAT")
endif ()
endif ()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set_target_properties(onnxruntime-genai-static PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
13 changes: 10 additions & 3 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ endif()
set_target_properties(python PROPERTIES OUTPUT_NAME "onnxruntime_genai")

if(MSVC)
target_compile_options(python PRIVATE "/sdl" PRIVATE "/Qspectre")
check_cxx_compiler_flag(-sdl HAS_SDL)
check_cxx_compiler_flag(-Qspectre HAS_QSPECTRE)
if (HAS_SDL)
target_compile_options(python PRIVATE "/sdl")
endif ()
if (HAS_QSPECTRE)
target_compile_options(python PRIVATE "/Qspectre")
endif ()
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
target_compile_options(python PRIVATE "/CETCOMPAT")
endif()
endif()
endif ()
endif ()

if(USE_CUDA AND CMAKE_CUDA_COMPILER)
cmake_policy(SET CMP0104 OLD)
Expand Down

0 comments on commit 0468a9d

Please sign in to comment.