-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
137 lines (113 loc) · 3.9 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
130
131
132
133
134
135
136
137
cmake_minimum_required(VERSION 3.5.0)
file(
STRINGS ${CMAKE_CURRENT_LIST_DIR}/VERSION PERCEMON_VERSION
LIMIT_COUNT 1
REGEX
"^(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$"
)
project(
PerceMon
VERSION ${PERCEMON_VERSION}
DESCRIPTION
"A library for efficient online monitoring for Spatio-Temporal Quality Logic on streams of perception data."
LANGUAGES CXX)
# Check if percemon is being used directly or via add_subdirectory
set(PERCEMON_MASTER_PROJECT OFF)
if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
set(PERCEMON_MASTER_PROJECT ON)
endif()
include(CMakePrintHelpers)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(CTest)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Options
option(PERCEMON_TEST "Build percemon test suite?" OFF)
option(PERCEMON_COVERAGE "Generate coverage.xml for test suite?" OFF)
option(PERCEMON_EXAMPLES "Build the examples?" OFF)
option(PERCEMON_DOCS "Build the docs?" OFF)
set(_PERCEMON_BUILD_THE_TESTS
OFF
CACHE INTERNAL "Easy option to build the tests")
if(PERCEMON_MASTER_PROJECT
AND PERCEMON_TEST
AND BUILD_TESTING)
set(_PERCEMON_BUILD_THE_TESTS
ON
CACHE INTERNAL "Easy option to build the tests")
endif()
if(PERCEMON_MASTER_PROJECT)
# Force color in compiler output as it will be easier to debug...
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using Clang
add_compile_options(-fcolor-diagnostics)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
add_compile_options(-fdiagnostics-color=always)
endif()
endif()
if(PERCEMON_COVERAGE)
set(ENABLE_COVERAGE
ON
CACHE BOOL "Enable coverage build." FORCE)
find_package(codecov)
endif()
# set(CMAKE_CXX_EXTENSIONS ON)
# Third party libraries and dependencies
include(ThirdPartyLibs)
add_subdirectory(third_party)
find_package(fmt QUIET)
find_package(cppitertools QUIET)
# Sources and actual library Add library and module
set(PERCEMON_SOURCES src/ast.cc src/topo.cc src/monitoring/default_monitor.cc
src/monitoring/horizon.cc)
add_library(PerceMon ${PERCEMON_SOURCES})
add_library(PerceMon::PerceMon ALIAS PerceMon)
target_include_directories(
PerceMon PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_include_directories(PerceMon PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_compile_features(PerceMon PUBLIC cxx_std_17)
target_link_libraries(PerceMon PUBLIC fmt::fmt cppitertools::cppitertools)
if(PERCEMON_COVERAGE)
add_coverage(PerceMon)
endif()
if(_PERCEMON_BUILD_THE_TESTS)
add_subdirectory(tests)
endif()
if(PERCEMON_DOCS)
add_subdirectory(doc)
endif()
if(PERCEMON_EXAMPLES)
add_subdirectory(examples)
endif()
if(PERCEMON_COVERAGE)
list(APPEND LCOV_REMOVE_PATTERNS "'${PROJECT_SOURCE_DIR}/third_party/*'"
"'${PROJECT_SOURCE_DIR}/tests/*'" "'${PROJECT_SOURCE_DIR}/examples/*'"
"'/usr/'")
coverage_evaluate()
endif()
include(GNUInstallDirs)
# Install catkin package.xml
install(FILES package.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/PerceMon)
install(
TARGETS PerceMon
EXPORT PerceMonTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
PerceMonConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion)
install(
EXPORT PerceMonTargets
FILE PerceMonTargets.cmake
NAMESPACE PerceMon::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PerceMon)
configure_file(cmake/PerceMonConfig.cmake.in PerceMonConfig.cmake @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PerceMonConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/PerceMonConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PerceMon)