-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
65 lines (49 loc) · 1.69 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
cmake_minimum_required(VERSION 3.16)
project("cpp-project-template" VERSION 1.0.0 LANGUAGES CXX)
# Global CMake variables are set here
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_EXPORT_COMPILE_COMMANDS ON)
# Options
option(ENABLE_WARNINGS "Enable to add warnings to a target." OFF)
option(ENABLE_TESTING "Enable a Unit Testing build." OFF)
option(ENABLE_COVERAGE "Enable a Code Coverage build." OFF)
option(ENABLE_CLANG_TIDY "Enable to add clang-tidy. (static analysis)" OFF)
option(ENABLE_CLANG_FORMAT "Enable to add clang-format. (formatting)" OFF)
# Message
message(STATUS "ENABLE_WARNINGS: ${ENABLE_WARNINGS}")
message(STATUS "ENABLE_TESTING: ${ENABLE_TESTING}")
message(STATUS "ENABLE_COVERAGE: ${ENABLE_COVERAGE}")
message(STATUS "ENABLE_CLANG_TIDY: ${ENABLE_CLANG_TIDY}")
message(STATUS "ENABLE_CLANG_FORMAT: ${ENABLE_CLANG_FORMAT}")
### CMAKE MODULES
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(FetchContent)
include(Warnings)
if(ENABLE_TESTING)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.12.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(googletest)
endif()
if(ENABLE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
endif()
if(ENABLE_CLANG_TIDY)
include(clang-tidy)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
endif()
if(ENABLE_CLANG_FORMAT)
include(clang-format)
endif()
### EXTERNAL LIBRARIES
### SUBDIRECTORIES
add_subdirectory(lib)
add_subdirectory(app)
add_subdirectory(tests)
### INSTALL TARGETS