-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
68 lines (54 loc) · 1.62 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
cmake_minimum_required(VERSION 3.22)
project(DummyProject)
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(
FATAL_ERROR
"In-source builds are disabled.
Please create a subfolder and use `cmake ..` inside it.
NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.
You must delete them, or cmake will refuse to work.")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# indicate the docs build
option(BUILD_DOC "Build docs" OFF)
# indicate the tests build
option(BUILD_TESTS "Build tests" OFF)
message("Project: ${PROJECT_NAME}")
message("Build Type: ${CMAKE_BUILD_TYPE}")
if(BUILD_DOC)
message("Documentation build enabled")
endif()
if(BUILD_TESTS)
message("Unit-tests build enabled")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Wextra -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra -Wpedantic")
#Tests:
include(FetchContent)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.15.0
)
FetchContent_MakeAvailable(googletest)
add_library(GTest::GTest INTERFACE IMPORTED)
target_link_libraries(GTest::GTest INTERFACE gtest_main)
if(BUILD_TESTS)
enable_testing()
endif()
add_subdirectory(tests)
target_link_libraries(DummyTest GTest::gtest_main)
include(GoogleTest)
add_test(DummyTest tests/DummyTest)
#Compile:
add_executable( ${PROJECT_NAME}
main.cc
)
add_subdirectory(src)
target_include_directories(${PROJECT_NAME} PRIVATE include)
target_include_directories(${PROJECT_NAME} PRIVATE src)
target_link_libraries(${PROJECT_NAME} DummyTarget)
#Docs:
add_subdirectory(docs)