-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
58 lines (51 loc) · 1.37 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
cmake_minimum_required(VERSION 3.22.1)
set(ARTIFACT math-tool)
project(${ARTIFACT})
# === External dependencies === #
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# === Build options === #
set(CMAKE_BUILD_TYPE "debug")
set(CMAKE_CXX_STANDARD "20")
set(CMAKE_CXX_COMPILER "clang++")
set(CXX_COMMON_FLAGS "-std=c++${CMAKE_CXX_STANDARD} -stdlib=libstdc++ -Wall -Werror")
set(CMAKE_EXPORT_COMPILE_COMMANDS "true")
if (CMAKE_BUILD_TYPE STREQUAL "debug")
set(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} -O0 -g -fsanitize=address,undefined,leak")
elseif (CMAKE_BUILD_TYPE STREQUAL "release")
set(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} -O3")
endif ()
# === idk === #
include_directories("src")
# === APP === #
file(GLOB_RECURSE SRC CONFIGURE_DEPENDS
src/*.hpp
src/*.cpp
)
add_executable(${ARTIFACT} ${SRC})
# === TEST === #
enable_testing()
file(
COPY
test/io
DESTINATION
${CMAKE_CURRENT_BINARY_DIR}/test
)
file(GLOB_RECURSE TEST CONFIGURE_DEPENDS
src/*.hpp
src/*/*.cpp
test/*.cpp
test/*.hpp
)
add_executable(${ARTIFACT}-test ${TEST})
target_link_libraries(
${ARTIFACT}-test
GTest::gtest_main
)
include(GoogleTest)
gtest_discover_tests(${ARTIFACT}-test)