-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
129 lines (106 loc) · 3.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
cmake_minimum_required(VERSION 3.11)
project(everest-log
VERSION 0.2.3
DESCRIPTION "EVerest logging library"
LANGUAGES CXX C
)
find_package(everest-cmake 0.1 REQUIRED
PATHS ../everest-cmake
)
# options
option(BUILD_BACKTRACE_SUPPORT "Build with backtrace support from libbacktrace" OFF)
option(${PROJECT_NAME}_BUILD_TESTING "Build unit tests, used if included as dependency" OFF)
option(BUILD_TESTING "Run unit tests" OFF)
option(BUILD_EXAMPLES "Build liblog example binaries." OFF)
option(LOG_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT})
option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF)
option(LIBLOG_USE_BOOST_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF)
# library dependencies
if (LIBLOG_USE_BOOST_FILESYSTEM)
message(STATUS "Using boost/filesystem instead of std::filesystem")
find_package(Boost COMPONENTS log_setup log filesystem REQUIRED)
else()
find_package(Boost COMPONENTS log_setup log REQUIRED)
endif()
# third party dependencies
add_subdirectory(3rd_party)
# logging library
add_subdirectory(lib)
# packaging
install(
FILES examples/logging.ini
DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/log
RENAME example-config.ini
)
if (LOG_INSTALL)
install(
TARGETS log
EXPORT log-targets
)
install(
DIRECTORY include/
TYPE INCLUDE
)
if (BUILD_BACKTRACE_SUPPORT)
# FIXME (aw): if statically build, we would need to install libbacktrace too
endif()
evc_setup_package(
NAME everest-log
NAMESPACE everest
EXPORT log-targets
ADDITIONAL_CONTENT
"find_dependency(Boost COMPONENTS log_setup log)"
)
endif()
# testing
if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} OR ${PROJECT_NAME}_BUILD_TESTING) AND BUILD_TESTING)
include(CTest)
add_subdirectory(tests)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
evc_include(CodeCoverage)
append_coverage_compiler_flags()
setup_target_for_coverage_gcovr_html(
NAME gcovr_coverage_liblog
EXECUTABLE test_config
DEPENDENCIES test_config everest
)
setup_target_for_coverage_lcov(
NAME lcov_coverage_liblog
EXECUTABLE test_config
DEPENDENCIES test_config everest
)
else()
message("Not running unit tests")
endif()
if(BUILD_EXAMPLES)
message("Building liblog example binaries.")
add_subdirectory(examples)
else()
message("Not building liblog example binaries.")
endif()
# configure clang-tidy if requested
if(CMAKE_RUN_CLANG_TIDY)
message("Running clang-tidy")
string(CONCAT CLANG_TIDY_CHECKS "*,"
"-llvmlibc*,"
"-fuchsia-default-arguments-calls,"
"-fuchsia-overloaded-operator,"
"-fuchsia-statically-constructed-objects,"
"-readability-function-cognitive-complexity,"
"-modernize-use-trailing-return-type,"
"-abseil-string-find-startswith,"
"-abseil-string-find-str-contains,"
";")
set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-header-filter='.*'
-checks=${CLANG_TIDY_CHECKS})
endif()
# build doxygen documentation if doxygen is available
find_package(Doxygen)
if(DOXYGEN_FOUND)
set( DOXYGEN_OUTPUT_DIRECTORY dist/docs )
doxygen_add_docs(doxygen-${PROJECT_NAME} include lib src)
else()
message("Doxygen is needed to generate documentation")
endif()