-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
111 lines (84 loc) · 3.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
cmake_minimum_required(VERSION 3.12)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/cmake-common-utils")
include(PreferClang)
include(PreferCcache)
include(DefaultDebug)
include(PreferGoldLinker)
project(PhoneHighlight VERSION 1.0 LANGUAGES CXX C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Manage dependencies with Conan
include(SetupConan)
find_package(boost_range REQUIRED)
find_package(boost_algorithm REQUIRED)
find_package(boost_locale REQUIRED)
find_package(icu REQUIRED)
find_package(range-v3 REQUIRED)
include(CTest)
# Add possibility to sanitize code
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/tools/cmake/sanitizers-cmake/cmake/")
find_package(Sanitizers REQUIRED)
# Add possibility to get code coverage
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/CMake-codecov/cmake")
find_package(codecov REQUIRED)
# Set global warnings configuration for all sub-projects
add_compile_options(-Wall -Wextra -pedantic -Werror)
set(LIB_NAME PhoneHighlight)
set(SRC_LIST
"src/PhoneHighlightAlt1.h"
"src/PhoneHighlightAlt1.cpp"
"src/PhoneHighlightUtil.h"
"src/PhoneHighlightUtil.cpp"
"src/PhoneHighlightAlt2.h"
"src/PhoneHighlightAlt2.cpp"
"src/PhoneHighlightAlt3.h"
"src/PhoneHighlightAlt3.cpp"
"src/PhoneHighlightAlt4.h"
"src/PhoneHighlightAlt4.cpp"
"src/UtfUtils.h"
"src/UtfUtils.cpp"
"src/UtfUtilsIcu.h"
"src/UtfUtilsIcu.cpp")
add_library(${LIB_NAME} ${SRC_LIST})
add_library(rms::${LIB_NAME} ALIAS ${LIB_NAME})
add_sanitizers(${LIB_NAME})
add_coverage(${LIB_NAME} src)
target_include_directories(${LIB_NAME} PUBLIC src)
target_compile_features(${LIB_NAME} PRIVATE cxx_std_14)
target_link_libraries(${LIB_NAME} PRIVATE boost_range::boost_range boost_algorithm::boost_algorithm boost_locale::boost_locale icu::icu range-v3::range-v3)
if (BUILD_TESTING)
find_package(Catch2 REQUIRED)
set(TEST_LIB_NAME "${LIB_NAME}_test")
set(TEST_SRC_LIST
"test/PhoneHighlightUtilTest.cpp"
"test/PhoneHighlightAlt1Test.cpp"
"test/PhoneHighlightAlt2Test.cpp"
"test/PhoneHighlightAlt3Test.cpp"
"test/PhoneHighlightAlt4Test.cpp"
"test/UtfUtilsTest.cpp"
"test/UtfUtilsIcuTest.cpp")
add_library(${TEST_LIB_NAME} OBJECT ${TEST_SRC_LIST})
add_library(rms::${TEST_LIB_NAME} ALIAS ${TEST_LIB_NAME})
add_sanitizers(${TEST_LIB_NAME})
list(APPEND LCOV_REMOVE_PATTERNS "'*/test/*'")
add_coverage(${TEST_LIB_NAME})
target_include_directories(${TEST_LIB_NAME} PRIVATE test)
target_compile_features(${TEST_LIB_NAME} PRIVATE cxx_std_14)
target_link_libraries(${TEST_LIB_NAME} PUBLIC rms::${LIB_NAME} Catch2::Catch2)
# define test runner
set(TEST_RUNNER_NAME testrunner)
add_executable(${TEST_RUNNER_NAME} "test/TestRunner.cpp")
target_compile_features(${TEST_RUNNER_NAME} PRIVATE cxx_std_14)
target_link_libraries(${TEST_RUNNER_NAME} PRIVATE ${TEST_LIB_NAME})
add_sanitizers(${TEST_RUNNER_NAME})
add_test(NAME all COMMAND ${TEST_RUNNER_NAME})
# define benchmark target
find_package(google-benchmark REQUIRED)
find_package(Threads REQUIRED)
set(BENCHMARK_NAME benchmark)
add_executable(${BENCHMARK_NAME} "benchmark/Benchmark.cpp")
target_compile_features(${BENCHMARK_NAME} PRIVATE cxx_std_14)
target_link_libraries(${BENCHMARK_NAME} PRIVATE rms::${LIB_NAME} google-benchmark::google-benchmark Threads::Threads)
endif()
include(ClangTidy)
include(PrepareDoxygen)
include(ClangStaticAnalyzer)