-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
67 lines (55 loc) · 1.52 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
cmake_minimum_required(VERSION 3.23)
project(dklib_math CXX)
# CMake setup
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "Compiler Version: ${CMAKE_CXX_COMPILER_VERSION}")
file(GLOB SRC_FILES "src/*.cpp" "src/**/*.cpp")
file(GLOB HDR_FILES "include/**/*.hpp" "include/**/*.h")
add_library(dk INTERFACE)
target_include_directories(
dk
INTERFACE
include/
)
target_link_libraries(
dk
)
# Testing Setup
file(GLOB TEST_SRC_FILES "tests/*.cpp" "tests/**/*.cpp")
file(GLOB TEST_HDR_FILES "tests/*.hpp" "tests/**/*.hpp")
find_package(doctest REQUIRED)
include(doctest)
set(DK_TEST_NAME "test_dklib")
add_executable(
${DK_TEST_NAME}
${TEST_SRC_FILES}
${TEST_HDR_FILES}
)
set_target_properties(
${DK_TEST_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests"
LINKER_LANGUAGE CXX
)
target_link_libraries(${DK_TEST_NAME} PUBLIC
dk
)
target_link_options(${DK_TEST_NAME}
BEFORE PUBLIC -fsanitize=undefined
PUBLIC -fsanitize=address
PUBLIC -fsanitize=leak
# PUBLIC -fsanitize=memory
PUBLIC -fno-omit-frame-pointer
PUBLIC -O1
)
target_link_libraries(${DK_TEST_NAME} PRIVATE doctest::doctest)
enable_testing()
doctest_discover_tests(${DK_TEST_NAME})