Skip to content

Commit

Permalink
Merge branch 'main' of github.com:microsoft/onnxruntime-genai into wa…
Browse files Browse the repository at this point in the history
…ngye/cg
  • Loading branch information
wangyems committed Apr 15, 2024
2 parents 27a1f4a + efbb450 commit 97ed6ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project(Generators LANGUAGES C CXX)
# All Options should be defined in cmake/options.cmake
include(cmake/options.cmake)
include(cmake/external/onnxruntime_external_deps.cmake)
include(cmake/util_func.cmake)

file(READ "VERSION_INFO" ver)
set(VERSION_INFO ${ver} CACHE STRING "Set the onnxruntime-genai version info.")
Expand Down Expand Up @@ -106,10 +107,7 @@ add_library(onnxruntime-genai-static STATIC ${generator_srcs})
target_include_directories(onnxruntime-genai PRIVATE ${ORT_HEADER_DIR})
target_include_directories(onnxruntime-genai-static PRIVATE ${ORT_HEADER_DIR})

if(CMAKE_GENERATOR_TOOLSET MATCHES "Visual Studio")
target_link_options(onnxruntime-genai PRIVATE "/CETCOMPAT")
target_compile_options(onnxruntime-genai PRIVATE "/sdl")
endif()
genai_set_target_compile_options(onnxruntime-genai)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set_target_properties(onnxruntime-genai-static PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
15 changes: 15 additions & 0 deletions cmake/util_func.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function(genai_set_target_compile_options target)
if (MSVC)
check_cxx_compiler_flag(-sdl HAS_SDL)
check_cxx_compiler_flag(-Qspectre HAS_QSPECTRE)
if (HAS_SDL)
target_compile_options(${target} PRIVATE "/sdl")
endif ()
if (HAS_QSPECTRE)
target_compile_options(${target} PRIVATE "/Qspectre")
endif ()
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND NOT USE_CUDA)
target_compile_options(${target} PRIVATE "/CETCOMPAT")
endif ()
endif ()
endfunction()
7 changes: 2 additions & 5 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include(${CMAKE_SOURCE_DIR}/cmake/cxx_standard.cmake)

include(${CMAKE_SOURCE_DIR}/cmake/util_func.cmake)
file(GLOB python_srcs CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
Expand All @@ -14,10 +14,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
set_target_properties(python PROPERTIES OUTPUT_NAME "onnxruntime_genai")

if(CMAKE_GENERATOR_TOOLSET MATCHES "Visual Studio")
target_link_options(python PRIVATE "/CETCOMPAT")
target_compile_options(python PRIVATE "/sdl" PRIVATE "/Qspectre")
endif()
genai_set_target_compile_options(python)

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

0 comments on commit 97ed6ea

Please sign in to comment.