-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
187 lines (157 loc) · 6.19 KB
/
CMakeLists.txt
File metadata and controls
187 lines (157 loc) · 6.19 KB
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
cmake_minimum_required(VERSION 3.28)
include(cmake/prelude.cmake)
project(
gdpr_controller
VERSION 0.1.0
DESCRIPTION "Controller module of GDPRuler"
HOMEPAGE_URL "https://example.com/"
LANGUAGES CXX
)
include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)
# ---------------------------------------------------------------------------------
# Load Configuration Options
# ---------------------------------------------------------------------------------
include(cmake/options.cmake)
# ---------------------------------------------------------------------------------
# External Dependencies
# ---------------------------------------------------------------------------------
# Add external GDPR logger
set(GDPR_LOGGER_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../gdpr-logger")
set(GDPR_LOGGER_BUILD_DIR "${CMAKE_BINARY_DIR}/external/gdpr-logger")
if(NOT EXISTS "${GDPR_LOGGER_SOURCE_DIR}/CMakeLists.txt")
message(FATAL_ERROR "GDPR Logger not found at: ${GDPR_LOGGER_SOURCE_DIR}")
endif()
add_subdirectory("${GDPR_LOGGER_SOURCE_DIR}" "${GDPR_LOGGER_BUILD_DIR}")
# Find system packages
find_package(Boost CONFIG REQUIRED COMPONENTS system)
find_package(OpenSSL REQUIRED COMPONENTS Crypto SSL)
find_package(ZLIB REQUIRED)
# Link Abseil if indexes enabled
if(ENABLE_GDPR_INDEX)
find_package(absl REQUIRED)
# Roaring bitmap library
include(FetchContent)
FetchContent_Declare(
roaring
GIT_REPOSITORY https://github.com/RoaringBitmap/CRoaring.git
GIT_TAG v4.4.2
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "" FORCE)
set(ENABLE_ROARING_TESTS OFF CACHE BOOL "" FORCE)
set(ROARING_BUILD_STATIC ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(roaring)
FetchContent_GetProperties(roaring)
if(NOT roaring_POPULATED)
FetchContent_Populate(roaring)
endif()
# Ensure the roaring target has PIC enabled
set_target_properties(roaring PROPERTIES POSITION_INDEPENDENT_CODE ON)
# The target is just 'roaring', not 'roaring::roaring'
# And we need to manually add include directories
set(ROARING_INCLUDE_DIR "${roaring_SOURCE_DIR}/include")
message(STATUS "Roaring include directory: ${ROARING_INCLUDE_DIR}")
endif()
# Find manual libraries
find_path(HIREDIS_HEADER hiredis)
find_library(HIREDIS_LIB hiredis)
find_path(REDIS_PLUS_PLUS_HEADER sw)
find_library(REDIS_PLUS_PLUS_LIB redis++)
find_path(ROCKSDB_HEADER rocksdb)
find_library(ROCKSDB_LIB rocksdb)
# ---------------------------------------------------------------------------------
# Main Library: gdpr_controller_lib
# ---------------------------------------------------------------------------------
# Collect source files
set(GDPR_CONTROLLER_SOURCES
source/default_policy.cpp
source/query.cpp
source/query_rewriter.cpp
source/gdpr_filter.cpp
source/gdpr_regulator.cpp
)
# Add index sources if enabled
if(ENABLE_GDPR_INDEX)
list(APPEND GDPR_CONTROLLER_SOURCES
source/gdpr_index/hashmap_index.cpp
source/gdpr_index/btree_index.cpp
source/gdpr_index/bit_inverted_index_hashset.cpp
source/gdpr_index/bit_inverted_index_roaring.cpp
source/gdpr_index/index_manager.cpp
)
endif()
add_library(gdpr_controller_lib SHARED
${GDPR_CONTROLLER_SOURCES}
)
target_include_directories(gdpr_controller_lib
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source>"
)
target_compile_features(gdpr_controller_lib PUBLIC cxx_std_20)
target_link_libraries(gdpr_controller_lib
PUBLIC
gdpr_logging_lib # Logger propagates to consumers
OpenSSL::Crypto
${REDIS_PLUS_PLUS_LIB}
${HIREDIS_LIB}
PRIVATE
# Private dependencies
${ROCKSDB_LIB}
${Boost_LIBRARIES}
ZLIB::ZLIB
OpenSSL::SSL
)
if(ENABLE_GDPR_INDEX)
target_link_libraries(gdpr_controller_lib
PUBLIC
absl::btree
absl::flat_hash_map
absl::flat_hash_set
roaring::roaring
)
target_include_directories(gdpr_controller_lib
PUBLIC
${ROARING_INCLUDE_DIR}
)
endif()
# ---------------------------------------------------------------------------------
# Helper Function for Executables
# ---------------------------------------------------------------------------------
function(add_gdpruler_executable name source_file output_name)
add_executable(${name} ${source_file})
set_property(TARGET ${name} PROPERTY OUTPUT_NAME ${output_name})
target_compile_features(${name} PRIVATE cxx_std_20)
target_link_libraries(${name} PRIVATE gdpr_controller_lib)
endfunction()
# ---------------------------------------------------------------------------------
# Executables
# ---------------------------------------------------------------------------------
add_gdpruler_executable(gdpr_controller_exe source/controller.cpp gdpr_controller)
add_gdpruler_executable(native_controller_exe source/native_controller.cpp native_controller)
add_gdpruler_executable(test_kv_client_driver_exe source/test_kv_client_driver.cpp test_kv_client_driver)
add_gdpruler_executable(direct_kv_client_exe source/direct_kv_client.cpp direct_kv_client)
# RocksDB server
add_executable(rocksdb_server_exe source/rocksdb_server/server.cpp)
set_property(TARGET rocksdb_server_exe PROPERTY OUTPUT_NAME rocksdb_server)
target_compile_features(rocksdb_server_exe PRIVATE cxx_std_20)
target_link_libraries(rocksdb_server_exe PRIVATE ${Boost_LIBRARIES} ${ROCKSDB_LIB})
# ---------------------------------------------------------------------------------
# Tests (Build with -DBUILD_TESTING=ON)
# ---------------------------------------------------------------------------------
include(CTest)
if(BUILD_TESTING)
message(STATUS "Building tests")
add_subdirectory(test)
endif()
# ---------------------------------------------------------------------------------
# Install and Dev Mode
# ---------------------------------------------------------------------------------
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/install-rules.cmake)
endif()
if(NOT gdpr_controller_DEVELOPER_MODE)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
message(AUTHOR_WARNING "Developer mode is intended for developers of gdpr_controller")
endif()
include(cmake/dev-mode.cmake)