-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
262 lines (233 loc) · 9.3 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
cmake_minimum_required(VERSION 3.10.2)
project(dynalib-utils VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE OFF)
# Cross-compiling Settings
if (UNIX AND NOT APPLE)
message(STATUS "Using Linux cross-compiling settings")
set(CMAKE_SYSTEM_NAME Linux)
# set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CLANG_DEFAULT_CXX_STDLIB libc++)
set(CLANG_DEFAULT_C_STDLIB libc)
set(CMAKE_C_COMPILER clang)
set(CMAKE_C_STANDARD 99)
set(CLANG_DEFAULT_CXX_STDLIB libc++)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_SHARED_LINKER_FLAGS "-lpthread")
set(CMAKE_EXE_LINKER_FLAGS "-lpthread")
endif()
if (APPLE AND NOT UNIX)
message(STATUS "Using Apple cross-compiling settings")
set(CMAKE_SYSTEM_NAME Apple)
set(CMAKE_SHARED_LINKER_FLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib")
set(CMAKE_EXE_LINKER_FLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib")
endif()
if (APPLE)
message(STATUS "Using Apple settings")
# include_directories( /Developer/Headers/FlatCarbon )
# find_library(CARBON_LIBRARY Carbon)
# find_library(QUICKTIME_LIBRARY QuickTime )
find_library(CORE_SERVICES_LIBRARY CoreServices REQUIRED)
mark_as_advanced(CORE_SERVICES_LIBRARY)
set(EXTRA_LIBS ${CORE_SERVICES_LIBRARY})
endif(APPLE)
# Tells executable to export all symbols to MODULE plugin libraries when they load
set(CMAKE_ENABLE_EXPORTS TRUE)
# Find packages (installed with Brew)
set(CURL_LIBRARY "-lcurl")
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time)
include_directories(${Boost_INCLUDE_DIRS})
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "../lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "../lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
set (TOP_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
set (UTILS_SOURCE_DIR ${TOP_SOURCE_DIR}/Utilities)
include_directories(./src)
set(UTIL_SOURCES
${TOP_SOURCE_DIR}/CreateUtilTypes.cpp
${UTILS_SOURCE_DIR}/Utils.cpp
${UTILS_SOURCE_DIR}/FileUtils.cpp
${UTILS_SOURCE_DIR}/Position.cpp
${UTILS_SOURCE_DIR}/Stopwatch.cpp
${UTILS_SOURCE_DIR}/PageFile.cpp
${UTILS_SOURCE_DIR}/DynaBuffer.cpp
${UTILS_SOURCE_DIR}/DynaArray.cpp
${UTILS_SOURCE_DIR}/DynaLogger.cpp
${UTILS_SOURCE_DIR}/DynaSort.cpp
${UTILS_SOURCE_DIR}/DynaList.cpp
${UTILS_SOURCE_DIR}/DynaBTree.cpp
${UTILS_SOURCE_DIR}/CheckForError.cpp
${UTILS_SOURCE_DIR}/DynaRingBuffer.cpp
${UTILS_SOURCE_DIR}/DynaAlloc.cpp
${UTILS_SOURCE_DIR}/DynaHashMap.cpp
${UTILS_SOURCE_DIR}/Synchronize.cpp
${UTILS_SOURCE_DIR}/DynaWaitQueue.cpp
${UTILS_SOURCE_DIR}/HashCoder.cpp
${UTILS_SOURCE_DIR}/SecurityToken.cpp
${UTILS_SOURCE_DIR}/StringWrapper.cpp
${UTILS_SOURCE_DIR}/TimeUtils.cpp
${UTILS_SOURCE_DIR}/PrintUtils.cpp
${UTILS_SOURCE_DIR}/DynaHashSet.cpp
${UTILS_SOURCE_DIR}/DynaLinkedList.cpp
${UTILS_SOURCE_DIR}/Graph/Node.cpp
${UTILS_SOURCE_DIR}/KAML/Manager.cpp
${UTILS_SOURCE_DIR}/KAML/File.cpp
${UTILS_SOURCE_DIR}/KAML/KAMLParser.cpp
${UTILS_SOURCE_DIR}/KAML/JSONParser.cpp
${UTILS_SOURCE_DIR}/KAML/JSONGenerator.cpp
${UTILS_SOURCE_DIR}/Parser/Tokenizer.cpp
${UTILS_SOURCE_DIR}/Parser/Token.cpp
${UTILS_SOURCE_DIR}/Parser/TokenizerContext.cpp
${UTILS_SOURCE_DIR}/Parser/CharacterClass.cpp
${UTILS_SOURCE_DIR}/date/tz.cpp
${UTILS_SOURCE_DIR}/DynaEventTable.cpp
${UTILS_SOURCE_DIR}/crypto/ISAAC64Random.cpp
${UTILS_SOURCE_DIR}/crypto/ISAACRandom.cpp
${UTILS_SOURCE_DIR}/crypto/SHA256.cpp
${UTILS_SOURCE_DIR}/UUID.cpp
${UTILS_SOURCE_DIR}/DynaCache.cpp
${UTILS_SOURCE_DIR}/DynaBufferCache.cpp
)
set(UTIL_INCLUDES
${UTILS_SOURCE_DIR}/Utils.h
${UTILS_SOURCE_DIR}/BitManip.h
${UTILS_SOURCE_DIR}/Exception.h
${UTILS_SOURCE_DIR}/FileUtils.h
${UTILS_SOURCE_DIR}/Position.h
${UTILS_SOURCE_DIR}/Stopwatch.h
${UTILS_SOURCE_DIR}/PageFile.h
${UTILS_SOURCE_DIR}/DynaBuffer.h
${UTILS_SOURCE_DIR}/DynaCache.h
${UTILS_SOURCE_DIR}/DynaCacheImpl.h
${UTILS_SOURCE_DIR}/DynaBufferCache.h
${UTILS_SOURCE_DIR}/DynaBufferCacheImpl.h
${UTILS_SOURCE_DIR}/DynaArray.h
${UTILS_SOURCE_DIR}/DynaArrayImpl.h
${UTILS_SOURCE_DIR}/DynaLogger.h
${UTILS_SOURCE_DIR}/DynaSort.h
${UTILS_SOURCE_DIR}/DynaSortImpl.h
${UTILS_SOURCE_DIR}/DynaList.h
${UTILS_SOURCE_DIR}/DynaBTree.h
${UTILS_SOURCE_DIR}/DynaListImpl.h
${UTILS_SOURCE_DIR}/CheckForError.h
${UTILS_SOURCE_DIR}/DynaRingBuffer.h
${UTILS_SOURCE_DIR}/DynaAlloc.h
${UTILS_SOURCE_DIR}/DynaAllocImpl.h
${UTILS_SOURCE_DIR}/DynaHashMap.h
${UTILS_SOURCE_DIR}/DynaHashMapImpl.h
${UTILS_SOURCE_DIR}/Synchronize.h
${UTILS_SOURCE_DIR}/DynaWaitQueue.h
${UTILS_SOURCE_DIR}/DynaWaitQueueImpl.h
${UTILS_SOURCE_DIR}/HashCoder.h
${UTILS_SOURCE_DIR}/IBufferCachePage.h
${UTILS_SOURCE_DIR}/ICacheConst.h
${UTILS_SOURCE_DIR}/ICacheFile.h
${UTILS_SOURCE_DIR}/ICachePage.h
${UTILS_SOURCE_DIR}/IComparable.h
${UTILS_SOURCE_DIR}/ICopyable.h
${UTILS_SOURCE_DIR}/IDynaBufferCacheListener.h
${UTILS_SOURCE_DIR}/IDynaCacheListener.h
${UTILS_SOURCE_DIR}/IDynaComparator.h
${UTILS_SOURCE_DIR}/IDynaEvent.h
${UTILS_SOURCE_DIR}/IDynaListener.h
${UTILS_SOURCE_DIR}/IHashable.h
${UTILS_SOURCE_DIR}/IndexConfig.h
${UTILS_SOURCE_DIR}/IntWrapper.h
${UTILS_SOURCE_DIR}/SecurityToken.h
${UTILS_SOURCE_DIR}/String.h
${UTILS_SOURCE_DIR}/StringWrapper.h
${UTILS_SOURCE_DIR}/TimeUtils.h
${UTILS_SOURCE_DIR}/TypeDefs.h
${UTILS_SOURCE_DIR}/PrintUtils.h
${UTILS_SOURCE_DIR}/DynaHashSet.h
${UTILS_SOURCE_DIR}/DynaHashSetImpl.h
${UTILS_SOURCE_DIR}/DynaLinkedList.h
${UTILS_SOURCE_DIR}/DynaLinkedListImpl.h
${UTILS_SOURCE_DIR}/DynaEventTable.h
${UTILS_SOURCE_DIR}/UUID.h
)
set(GRAPH_INCLUDES
${UTILS_SOURCE_DIR}/Graph/Node.h
)
set(PARSER_INCLUDES
${UTILS_SOURCE_DIR}/Parser/Tokenizer.h
${UTILS_SOURCE_DIR}/Parser/Token.h
${UTILS_SOURCE_DIR}/Parser/TokenizerContext.h
${UTILS_SOURCE_DIR}/Parser/CharacterClass.h
${UTILS_SOURCE_DIR}/Parser/ErrorContext.h
${UTILS_SOURCE_DIR}/Parser/ASCIICharClass.h
)
set(KAML_INCLUDES
${UTILS_SOURCE_DIR}/KAML/Manager.h
${UTILS_SOURCE_DIR}/KAML/File.h
${UTILS_SOURCE_DIR}/KAML/KAMLParser.h
${UTILS_SOURCE_DIR}/KAML/JSONParser.h
${UTILS_SOURCE_DIR}/KAML/JSONGenerator.h
)
set(DATE_INCLUDES
${UTILS_SOURCE_DIR}/date/tz.h
)
set(CRYPTO_INCLUDES
${UTILS_SOURCE_DIR}/crypto/ISAAC64Random.h
${UTILS_SOURCE_DIR}/crypto/ISAACRandom.h
${UTILS_SOURCE_DIR}/crypto/SHA256.h
${UTILS_SOURCE_DIR}/crypto/standard.h
)
# Specify the libraries that will be linked in
add_library(dynalib-utils SHARED ${UTIL_SOURCES})
# Configure properties for the libraries
set_target_properties(dynalib-utils PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 1.0)
# Link each of the libraries
target_link_libraries(dynalib-utils ${CURL_LIBRARIES})
# Build the test executable
add_executable(testKaml ${TOP_SOURCE_DIR}/examples/testKaml.cpp)
target_link_libraries(testKaml PUBLIC dynalib-utils)
# Enable unit testing
# enable_testing()
# add_subdirectory(src/UnitTests UnitTests)
add_custom_target(TARGET testKaml POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${TOP_SOURCE_DIR}/examples/sample.kaml ${CMAKE_CURRENT_BINARY_DIR}/sample.kaml)
install(TARGETS dynalib-utils LIBRARY DESTINATION lib)
install(FILES ${UTIL_INCLUDES} DESTINATION include/dynalib)
install(FILES ${GRAPH_INCLUDES} DESTINATION include/dynalib/Graph)
install(FILES ${PARSER_INCLUDES} DESTINATION include/dynalib/Parser)
install(FILES ${KAML_INCLUDES} DESTINATION include/dynalib/KAML)
install(FILES ${DATE_INCLUDES} DESTINATION include/dynalib/date)
install(FILES ${CRYPTO_INCLUDES} DESTINATION include/dynalib/crypto)
# Include extra CMake files that are used for testing and linting.
include(${CMAKE_SOURCE_DIR}/cmake/unit_test.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/clang_tools.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/cppcheck.cmake)
#include(${CMAKE_SOURCE_DIR}/cmake/code-coverage.cmake)
#add_code_coverage()
#add_code_coverage_all_targets()
# Any source files added to include/ or src/ will automatically be added to the project.
file(GLOB_RECURSE INCLUDE_FILES ${CMAKE_SOURCE_DIR}/include/*.h)
# If external libraries are needed, use find_library() and target_link_libraries()
# to dynamically link them to your executable. Generally, you'll want to install
# them onto the host using your OS's package manager.
# Example:
# find_library(LIB_FMT fmt)
# target_link_libraries(clang-blueprint ${LIB_FMT})
# Enable all warnings except for no-sign-compare, which Clang disables
# by default.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare \
-Wreorder -Winfinite-recursion -Wmismatched-tags -Wunused-private-field")
option(WERROR "Turn warnings into errors" OFF)
if (WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif ()
# auto install after build
add_custom_command(
TARGET testKaml
POST_BUILD
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install
)