forked from JustinBonus/claymore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_cpp.cmake
40 lines (39 loc) · 1.57 KB
/
setup_cpp.cmake
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
function(add_cpp_executable binary)
add_executable(${binary} ${ARGN})
target_compile_options(${binary}
INTERFACE "${CMAKE_CXX_FLAGS} -O3 -fPIE -fuse-ld=lld -fvisibility=hidden -fsanitize=cfi ") # -flto=thin -fsanitize=cfi
# -march=sapphirerapids -mtune=sapphirerapids
# -fsanitize=address memory thread
set_target_properties(${binary}
PROPERTIES CXX_STANDARD 20
LINKER_LANGUAGE CXX
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_features(${binary} INTERFACE cxx_std_20)
target_link_libraries(${binary}
PUBLIC pthread
#stdc++
fmt
)
message("-- [${binary}]\tcpp executable build config")
endfunction(add_cpp_executable)
function(add_cpp_executable_debug binary)
add_executable(${binary} ${ARGN})
target_compile_options(${binary}
INTERFACE "${CMAKE_CXX_FLAGS} -O2 -fPIE -fuse-ld=lld -fvisibility=hidden"
"-fsanitize=address -fsanitize=memory -fsanitize=thread -fno-sanitize-trap=cfi -fsanitize=cfi") # -flto=thin -fsanitize=cfi
# -march=sapphirerapids -mtune=sapphirerapids
# -fsanitize=address memory thread
set_target_properties(${binary}
PROPERTIES CXX_STANDARD 20
LINKER_LANGUAGE CXX
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_features(${binary} INTERFACE cxx_std_20)
target_link_libraries(${binary}
PUBLIC pthread
#stdc++
fmt
)
message("-- [${binary}]\tcpp debug executable build config")
endfunction(add_cpp_executable_debug)