forked from anand-bala/signal-temporal-logic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
185 lines (151 loc) · 5.12 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
cmake_minimum_required(VERSION 3.11)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Check if signaltl is being used directly or via add_subdirectory
set(SIGNALTL_MASTER_PROJECT OFF)
if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SIGNALTL_MASTER_PROJECT ON)
endif()
include(cmake/Version.cmake)
message(STATUS "signaltl: v${SIGNALTL_FULL_VERSION}")
project(
signaltl
VERSION "${SIGNALTL_VERSION}"
DESCRIPTION
"A library for efficiently working with Signal Temporal Logic (STL) and its quantitative semantics"
LANGUAGES CXX
)
include(CMakeDependentOption)
# Options
option(BUILD_CORE_ONLY "Build only the core AST and Signal" OFF)
cmake_dependent_option(
BUILD_PARSER "Don't build the parser" ON "NOT BUILD_CORE_ONLY" OFF
)
cmake_dependent_option(
BUILD_ROBUSTNESS "Don't build the robust semantics for STL" ON
"NOT BUILD_CORE_ONLY" OFF
)
option(BUILD_DOCS "Build the documentation?" OFF)
option(BUILD_EXAMPLES "Build the examples?" ${SIGNALTL_MASTER_PROJECT})
# TODO: Turn this on once the library is stable.
option(BUILD_PYTHON_BINDINGS "Build the Python extension?"
OFF
)
option(ENABLE_CACHE "Enable cache if available" ${SIGNALTL_MASTER_PROJECT})
option(ENABLE_TESTING "Build signaltl test suite?" ${SIGNALTL_MASTER_PROJECT})
# Coverage needs to be explicitly turned on, but available only if Testing is
# enabled.
cmake_dependent_option(
ENABLE_COVERAGE "Generate coverage.xml for test suite?" OFF "ENABLE_TESTING"
OFF
)
option(ENABLE_STATIC_ANALYSIS "Enable clang-tidy and include-what-you-use" OFF)
set(_SIGNALTL_BUILD_THE_TESTS
OFF
CACHE INTERNAL "Easy option to build the tests"
)
if((SIGNALTL_MASTER_PROJECT AND ENABLE_TESTING) AND BUILD_TESTING)
set(_SIGNALTL_BUILD_THE_TESTS
ON
CACHE INTERNAL "Easy option to build the tests"
)
endif()
if(NOT BUILD_CORE_ONLY)
if(NOT NO_BUILD_PARSER)
set(BUILD_PARSER
ON
CACHE BOOL "Build the parser"
)
endif()
if(NOT NO_BUILD_ROBUSTNESS)
set(BUILD_ROBUSTNESS
ON
CACHE BOOL "Build the robustness"
)
endif()
endif()
# ##############################################################################
# Include CMake Modules #
# ##############################################################################
include(StandardProjectSettings)
include(PreventInSourceBuilds)
include(CompilerWarnings)
include(Cache)
include(StaticAnalyzers)
include(CTest)
include(Codecov)
# ##############################################################################
# Some Global Configuration #
# ##############################################################################
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# ##############################################################################
# Third Party dependencies #
# ##############################################################################
include(ThirdPartyDeps)
# ##############################################################################
# Sources #
# ##############################################################################
add_subdirectory(src)
add_library(signaltl::signaltl ALIAS signaltl)
add_subdirectory(python_bindings)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(ENABLE_TESTING)
add_subdirectory(tests)
coverage_evaluate()
endif()
if(BUILD_DOCS)
add_subdirectory(docs)
endif()
# ##############################################################################
# Installation #
# ##############################################################################
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(SIGNALTL_CMAKECONFIG_INSTALL_DIR
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
CACHE STRING "install path for signaltlConfig.cmake"
)
set(INSTALL_CONFIGDIR ${SIGNALTL_CMAKECONFIG_INSTALL_DIR})
install(
TARGETS signaltl
EXPORT signaltl-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY ${SIGNALTL_INCLUDE_DIRS} TYPE INCLUDE)
install(
EXPORT signaltl-targets
FILE signaltlTargets.cmake
NAMESPACE signaltl::
DESTINATION ${INSTALL_CONFIGDIR}
)
# Create a ConfigVersion.cmake file
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/signaltlConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/signaltlConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/signaltlConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
# Install the config, configversion and custom find modules
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/signaltlConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/signaltlConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
export(
EXPORT signaltl-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/signaltlTargets.cmake
NAMESPACE signaltl::
)
# Register package in user's package registry
export(PACKAGE signaltl)