-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
92 lines (72 loc) · 2.46 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
cmake_minimum_required(VERSION 3.12)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-common-utils")
include(PreferClang)
include(PreferCcache)
include(DefaultDebug)
include(PreferGoldLinker)
project(cpputils VERSION 1.0 LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Manage dependencies
include(PrepareConan)
# This will set output dir to bin
list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}")
include(conanbuildinfo)
conan_basic_setup(TARGETS)
include(CTest)
# Add possibility to sanitize code
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/sanitizers-cmake/cmake/")
find_package(Sanitizers REQUIRED)
# Add possibility to get code coverage
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMake-codecov/cmake")
find_package(codecov REQUIRED)
set(SRC_LIST
"src/core/general_error.cc"
"src/core/general_error.h"
"src/util/enum_util.h"
"src/util/logger.cc"
"src/util/logger.h"
"src/util/scope_guard.h"
"src/util/singleton.h"
"src/util/static_string.h"
"src/util/boost_string_fmt.h"
"src/util/type_traits.h"
"src/util/cloneable.h")
add_executable(testrunner
"${SRC_LIST}"
"test/core/general_error_test.cc"
"test/core/testrunner.cc"
"test/util/enum_util_test.cc"
"test/util/logger_test.cc"
"test/util/rvo_test.cc"
"test/util/scope_guard_test.cc"
"test/util/singleton_test.cc"
"test/util/static_string_test.cc"
"test/util/fmt_test.cc"
"test/util/boost_string_fmt_test.cc"
"test/util/cloneable_test.cc"
"test/misc/inter_layer_test")
add_sanitizers(testrunner)
add_coverage(testrunner)
# Setup clang-tidy target
include(ClangTidy)
# Setup doxygen target
include(PrepareDoxygen)
# Setup clang static analyzer
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Setup clang static analyzer: ${CMAKE_CXX_COMPILER}")
add_custom_target(clang-static-analyzer
COMMAND scan-build --use-analyzer=/usr/bin/clang++-7 make
VERBATIM)
else()
message(STATUS "Static analysed target not created. Current CXX is not clang")
endif()
target_include_directories(testrunner
PRIVATE
src
test)
target_compile_options(testrunner PRIVATE -Wextra -Werror)
target_link_libraries(testrunner PRIVATE CONAN_PKG::gtest CONAN_PKG::log4cplus CONAN_PKG::boost CONAN_PKG::fmt)
add_test(NAME all COMMAND testrunner)
#Copy default config to the output dir
configure_file(config/logger.cfg bin/logger.cfg COPYONLY)