-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
69 lines (55 loc) · 1.72 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 3.13)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
project(OrtKI)
find_package(onnxruntime REQUIRED CONFIG)
set(SRCS
src/op_executor.cpp
src/allocator_manager.cpp
src/default_providers.cpp
src/environment.cpp
src/c_api.cpp
src/operators.cpp
src/operators_patch.cpp
src/util.cpp)
add_library(ortki ${SRCS})
#add_compile_definitions(ONNX_ML=1)
#add_compile_definitions(ONNX_NAMESPACE=onnx)
set(onnxruntime_DISABLE_RTTI OFF)
set(onnxruntime_BUILD_UNIT_TESTS OFF)
set(onnxruntime_DISABLE_CONTRIB_OPS ON)
set(onnxruntime_DISABLE_ML_OPS ON)
set(onnxruntime_DISABLE_SPARSE_TENSORS OFF)
set(onnxruntime_DISABLE_OPTIONAL_TYPE ON)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
if(MSVC)
target_compile_options(ortki PRIVATE /wd4127)
target_compile_definitions(ortki PRIVATE NOMINMAX NOGDI)
else()
if (NOT APPLE)
target_link_options(ortki PRIVATE -Wl,--no-undefined)
endif()
endif()
set(INCLUDE_DIRS
include)
target_include_directories(ortki PUBLIC ${INCLUDE_DIRS})
target_include_directories(ortki PRIVATE ${onnxruntime_INCLUDE_DIR}/onnxruntime)
target_link_libraries(ortki PRIVATE onnxruntime::onnxruntime)
if (MSVC)
elseif(APPLE)
else()
target_link_options(ortki PRIVATE -static-libstdc++)
endif()
if(BUILD_TEST_EXE)
add_executable(run src/main.cpp)
target_link_libraries(run PRIVATE ortki)
endif()
install(TARGETS ortki
EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY ${INCLUDE_DIRS}/
DESTINATION include/ortki
FILES_MATCHING PATTERN "*.h*")