-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
66 lines (49 loc) · 2.04 KB
/
Copy pathCMakeLists.txt
File metadata and controls
66 lines (49 loc) · 2.04 KB
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
cmake_minimum_required(VERSION 3.22.0)
set(CMAKE_CXX_STANDARD 23)
project(nons)
# main part of project
option(BUILD_PROJECT "Build project" ON)
option(PROFILING "Add profiling flag" OFF)
if (PROFILING)
message(STATUS "Profiling enabled")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
endif()
file(GLOB_RECURSE src "source/*.cpp")
list(REMOVE_ITEM src "${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp")
file(GLOB_RECURSE tests "test/*.cpp")
include_directories(
${CMAKE_SOURCE_DIR}/source/
${CMAKE_SOURCE_DIR}/external/spdlog/include/
${CMAKE_SOURCE_DIR}/external/cxxopts/include/
)
add_subdirectory(${CMAKE_SOURCE_DIR}/external/yaml-cpp/)
add_subdirectory(${CMAKE_SOURCE_DIR}/external/matplotplusplus/)
if (BUILD_PROJECT)
set(TARGET_NAME "${PROJECT_NAME}")
add_executable(${TARGET_NAME} ${src} source/main.cpp)
target_link_libraries(${TARGET_NAME} yaml-cpp matplot)
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Werror -Wextra)
if (DEFINED LOG_LEVEL)
target_compile_definitions(${TARGET_NAME} PRIVATE LOG_LEVEL=${LOG_LEVEL})
endif()
target_include_directories(${TARGET_NAME} PUBLIC "source")
endif()
# tests
option(BUILD_TESTS "Build tests" ON)
if(BUILD_TESTS)
add_subdirectory(external/googletest)
set(TEST_NAME "test_nons")
add_executable(${TEST_NAME} ${src} ${tests})
target_include_directories(${TEST_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/external/yaml-cpp/include)
target_include_directories(${TEST_NAME} PUBLIC "source")
target_compile_definitions(${TEST_NAME} PRIVATE PROJECT_ROOT_DIR="${CMAKE_SOURCE_DIR}")
target_compile_options(${TEST_NAME} PRIVATE -Wall -Werror -Wextra)
target_link_libraries(${TEST_NAME} gtest gmock gtest_main yaml-cpp matplot)
if (DEFINED LOG_LEVEL)
target_compile_definitions(${TEST_NAME} PRIVATE LOG_LEVEL=${LOG_LEVEL})
endif()
enable_testing()
add_test(NAME MyTests COMMAND ${TEST_NAME})
endif()