-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
77 lines (64 loc) · 2.38 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
70
71
72
73
74
75
76
77
cmake_minimum_required(VERSION 3.16)
project("SmartServing" C CXX CUDA)
option(SMART_ENABLE_ASAN "Enable address santizer" OFF)
option(SMART_ENABLE_UBSAN "Enable undefined santizer" OFF)
option(SMART_ENABLE_LTO "Enable link-time optimization" OFF)
option(SMART_ENABLE_WERROR "Enable -Werror" OFF)
option(SMART_WITH_QNN "Enable QNN backend" OFF)
option(SMART_WITH_CUDA "Enable CUDA backend" OFF)
option(SMART_WITH_PERFETTO "Enable Perfetto tracing" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED true)
set(CMAKE_CUDA_STANDARD 20)
set(CMAKE_CUDA_STANDARD_REQUIRED true)
# Remove -DNDEBUG from the default Release flags
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
# Remove -DNDEBUG from the default RelWithDebInfo flags
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
set(BUILD_SHARED_LIBS OFF)
if (SMART_ENABLE_ASAN)
if (ANDROID)
add_compile_options(-fsanitize=hwaddress -fno-omit-frame-pointer)
link_libraries(-fsanitize=hwaddress)
else()
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
link_libraries(-fsanitize=address)
endif()
endif()
if (SMART_ENABLE_UBSAN)
if (ANDROID)
add_compile_options(-fsanitize=undefined,bounds -static-libsan)
link_libraries(-fsanitize=undefined,bounds -static-libsan)
else()
add_compile_options(-fsanitize=undefined)
link_libraries(-fsanitize=undefined)
endif()
endif()
if (SMART_ENABLE_LTO)
if (${CMAKE_C_COMPILER_ID} MATCHES "Clang")
add_compile_options(-flto=thin)
else()
add_compile_options(-flto)
endif()
endif()
add_custom_target(
MAKEDIR_OUT
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/out
)
function(smart_add_artifact target_name)
add_custom_command(
TARGET ${target_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${target_name}>
${CMAKE_BINARY_DIR}/out/smart-${target_name}
)
endfunction()
add_subdirectory(libs)
add_subdirectory(src)
add_subdirectory(app)
add_subdirectory(tools)