-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
225 lines (191 loc) · 7.94 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
cmake_minimum_required(VERSION 3.25)
# Set a consistent MACOSX_RPATH default across all CMake versions.
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
project(ChronoLog LANGUAGES CXX)
#------------------------------------------------------------------------------
# Version information
#------------------------------------------------------------------------------
set(CHRONOLOG_VERSION_MAJOR "0")
set(CHRONOLOG_VERSION_MINOR "7")
set(CHRONOLOG_VERSION_PATCH "0")
set(CHRONOLOG_PACKAGE "ChronoLog")
set(CHRONOLOG_PACKAGE_NAME "CHRONOLOG")
set(CHRONOLOG_PACKAGE_VERSION "${CHRONOLOG_VERSION_MAJOR}.${CHRONOLOG_VERSION_MINOR}.${CHRONOLOG_VERSION_PATCH}")
set(CHRONOLOG_PACKAGE_VERSION_MAJOR "${CHRONOLOG_VERSION_MAJOR}.${CHRONOLOG_VERSION_MINOR}")
set(CHRONOLOG_PACKAGE_VERSION_MINOR "${CHRONOLOG_VERSION_PATCH}")
set(CHRONOLOG_PACKAGE_STRING "${CHRONOLOG_PACKAGE_NAME} ${CHRONOLOG_PACKAGE_VERSION}")
set(CHRONOLOG_PACKAGE_TARNAME "${CHRONOLOG_PACKAGE}")
#------------------------------------------------------------------------------
# Setup install and output Directories
#------------------------------------------------------------------------------
#if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX /home/$ENV{USER}/chronolog)
#endif()
if(NOT CHRONOLOG_INSTALL_BIN_DIR)
set(CHRONOLOG_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
endif()
if(NOT CHRONOLOG_INSTALL_LIB_DIR)
set(CHRONOLOG_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
endif()
if(NOT CHRONOLOG_INSTALL_INCLUDE_DIR)
set(CHRONOLOG_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
endif()
if(NOT CHRONOLOG_INSTALL_DATA_DIR)
set(CHRONOLOG_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share)
endif()
#------------------------------------------------------------------------------
# Disallow in-source build. This checks that there is a defined and separate /build folder
#------------------------------------------------------------------------------
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR
"ChronoLog requires an out of source build. "
"Please create a separate binary directory and run CMake there.")
endif()
#------------------------------------------------------------------------------
# Set CXX Standard if one was not defined
#------------------------------------------------------------------------------
if(NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
#find_package(OpenMP)
#find_package(IntelDPCPP REQUIRED)
#------------------------------------------------------------------------------
# Options for compilations
#------------------------------------------------------------------------------
option(SET_WERROR "Elevate warnings to errors" OFF)
option(BUILD_SHARED_LIBS "Build with shared libraries." ON)
option(CHRONOLOG_ENABLE_COVERAGE "Enable code coverage." OFF)
option(CHRONOLOG_USE_ADDRESS_SANITIZER "Enable -fsanitize=address in Debug builds" ON)
option(CHRONOLOG_USE_THREAD_SANITIZER "Enable -fsanitize=thread in Debug builds" OFF)
option(CHRONOLOG_BUILD_TESTING "Build the testing tree." ON)
option(CHRONOLOG_ENABLE_DOXYGEN "Enable Doxygen documentation generation." OFF)
#------------------------------------------------------------------------------
# Define the compiler flags
#------------------------------------------------------------------------------
# TODO Should we consider the posibility of a user passing their own fflags through CMAKE_CXX_FLAGS
# Encapsulate everything around if(NOT CMAKE_CXX_FLAGS)
# Check Hermes for hwo they delete flags automatically
#if(SET_WERROR)
# add_compile_options(-Wall)
# add_compile_options(-Wextra)
# add_compile_options(-Werror)
#else()
# add_compile_options(-Wall)
# add_compile_options(-Wextra)
#endif()
#set(CMAKE_BUILD_TYPE "Debug")
# Change some compilation flags depending on the build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Compiling ChronoLog in Debug Mode")
# add_compile_options(-g3)
add_compile_options(-O0)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O0 -g")
#if (CHRONOLOG_USE_ADDRESS_SANITIZER)
# add_compile_options(-fsanitize=address)
#endif()
#if (CHRONOLOG_USE_THREAD_SANITIZER)
# add_compile_options(-fsanitize=thread)
#endif()
#if (CHRONOLOG_USE_THREAD_SANITIZER AND CHRONOLOG_USE_ADDRESS_SANITIZER)
# message(FATAL_ERROR "Cannont use -fsanitize=address and -fsanitize=thread "
# "at the same time")
#endif()
else()
message("Compiling ChronoLog in release Mode")
add_compile_options(-O3 -lm)
#add_compile_options(-Wno-switch-unreachable -Wno-return-type)
endif()
#------------------------------------------------------------------------------
# Error Checking on incompatible flags.
#------------------------------------------------------------------------------
if(CHRONOLOG_ENABLE_COVERAGE)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Use code coverage with debug mode")
endif()
endif()
#------------------------------------------------------------------------------
# Transform flags from boolean to meaningful usages.
#------------------------------------------------------------------------------
if(BUILD_SHARED_LIBS)
set(CHRONOLOG_LIBTYPE SHARED)
else()
set(CHRONOLOG_LIBTYPE STATIC)
endif()
#-----------------------------------------------------------------------------
# Dependencies common to all subdirectories
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Coverage
#-----------------------------------------------------------------------------
if(CHRONOLOG_ENABLE_COVERAGE)
set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage" CACHE STRING
"Flags to the coverage program to perform coverage inspection")
mark_as_advanced(COVERAGE_FLAGS)
macro(set_coverage_flags target)
set_target_properties(${target}
PROPERTIES
COMPILE_FLAGS ${COVERAGE_FLAGS}
LINK_FLAGS ${COVERAGE_FLAGS}
)
endmacro()
endif()
#-----------------------------------------------------------------------------
# Documentation
#-----------------------------------------------------------------------------
if(CHRONOLOG_ENABLE_DOXYGEN)
message(STATUS "Doxygen enable, generating documentation")
find_package(Doxygen REQUIRED)
include(UseDoxygenDoc)
add_doxygen_doc(
BUILD_DIR
${CMAKE_CURRENT_BINARY_DIR}/_build
DOXY_FILE
${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
TARGET_NAME
dox
COMMENT
"HTML documentation"
)
endif()
#-----------------------------------------------------------------------------
# Linting
#-----------------------------------------------------------------------------
add_custom_target(lint COMMAND cpplint --recursive
--exclude=${CMAKE_CURRENT_SOURCE_DIR}/build
--exclude=${CMAKE_CURRENT_SOURCE_DIR}/cmake-build-debug
--exclude=${CMAKE_CURRENT_SOURCE_DIR}/external_libs
--exclude=${CMAKE_CURRENT_SOURCE_DIR}/doc
--exclude=${CMAKE_CURRENT_SOURCE_DIR}/CI
${CMAKE_CURRENT_SOURCE_DIR})
#-----------------------------------------------------------------------------
# Source
#-----------------------------------------------------------------------------
if(CHRONOLOG_BUILD_TESTING)
message(STATUS "Tests enable")
include(CTest)
endif()
# ChronoLog client library
add_subdirectory(Client)
# ChronoVisor
add_subdirectory(ChronoVisor)
# ChronoKeeper
add_subdirectory(ChronoKeeper)
add_subdirectory(ChronoGrapher)
# ChronoStore
add_subdirectory(ChronoStore)
# custom
add_custom_target(make_all cd ${CMAKE_BINARY_DIR} && make)
#Tests
if(CHRONOLOG_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
#if(CHRONOLOG_ENABLE_PYTHON_BINDINGS)
message("Python binding enabled")
add_subdirectory(python_client)
#endif()