-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
221 lines (175 loc) · 7.54 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
# ---------------------------------------------------------------------------- #
cmake_minimum_required(VERSION 3.16)
include(FetchContent)
project(padll VERSION 1.0.0 DESCRIPTION "padll: ...")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Setup the options that CMake can take in
option(PADLL_INSTALL "Install PADLL's header and library" ON)
option(PADLL_BUILD_TESTS "Build PADLL's unit tests" OFF)
option(PADLL_BUILD_BENCHMARKS "Build benchmarks" ON)
option(FETCH_FROM_GIT "Fetch PAIO repo from github" OFF)
# Path to (local) PAIO lib
set(PAIO_LOCAL_PATH "/path/to/paio/build")
# Setup the basic C++ Compiler flags
if (APPLE)
message(STATUS "Detecting Local Environment (apple-clang)")
option(IS_LOCAL "Install PADLL in local setup" ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC")
endif (APPLE)
if (UNIX AND NOT APPLE)
message(STATUS "Detecting UNIX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -pthread -fPIC -Wl,--no-as-needed -ldl")
endif ()
# Install PADLL to be used in production. This option will modify the
# compilation options, regarding compiler-based optimizations.
option(PRODUCTION "Compiling with release mode" ON)
if (PRODUCTION)
message(STATUS "Compiling with compiler-based optimizations (-O3)")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
else()
message(STATUS "Compiling with default compiling options")
endif (PRODUCTION)
# Test whether -Wthread-safety is available. See
# https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wthread-safety HAVE_CLANG_THREAD_SAFETY)
# ---------------------------------------------------------------------------- #
# padll
add_library(padll SHARED "")
set_target_properties(
padll
PROPERTIES
# CXX_VISIBILITY_PRESET hidden
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
target_include_directories(padll PUBLIC include)
if (HAVE_CLANG_THREAD_SAFETY)
target_compile_options(padll PUBLIC -Wthread-safety)
endif (HAVE_CLANG_THREAD_SAFETY)
find_package(Threads REQUIRED)
target_link_libraries(padll Threads::Threads)
target_sources(
padll
PUBLIC
${PROJECT_SOURCE_DIR}/include/padll/configurations/libc_calls.hpp
${PROJECT_SOURCE_DIR}/include/padll/interface/ldpreloaded/ld_preloaded_posix.hpp
${PROJECT_SOURCE_DIR}/include/padll/interface/ldpreloaded/dlsym_hook_libc.hpp
${PROJECT_SOURCE_DIR}/include/padll/interface/native/posix_file_system.hpp
${PROJECT_SOURCE_DIR}/include/padll/interface/passthrough/posix_passthrough.hpp
${PROJECT_SOURCE_DIR}/include/padll/library_headers/libc_enums.hpp
${PROJECT_SOURCE_DIR}/include/padll/library_headers/libc_headers.hpp
${PROJECT_SOURCE_DIR}/include/padll/options/options.hpp
${PROJECT_SOURCE_DIR}/include/padll/stage/data_plane_stage.hpp
${PROJECT_SOURCE_DIR}/include/padll/stage/mount_point_entry.hpp
${PROJECT_SOURCE_DIR}/include/padll/stage/mount_point_table.hpp
${PROJECT_SOURCE_DIR}/include/padll/statistics/statistic_entry.hpp
${PROJECT_SOURCE_DIR}/include/padll/statistics/statistics.hpp
${PROJECT_SOURCE_DIR}/include/padll/utils/log.hpp
${PROJECT_SOURCE_DIR}/include/padll/third_party/enum.h
${PROJECT_SOURCE_DIR}/include/padll/third_party/tabulate.hpp
${PROJECT_SOURCE_DIR}/include/padll/third_party/xoshiro.hpp
)
target_sources(
padll
PRIVATE
src/interface/ldpreloaded/ld_preloaded_posix.cpp
src/interface/native/posix_file_system.cpp
src/interface/passthrough/posix_passthrough.cpp
src/stage/data_plane_stage.cpp
src/stage/mount_point_entry.cpp
src/stage/mount_point_table.cpp
src/statistics/statistic_entry.cpp
src/statistics/statistics.cpp
src/utils/log.cpp
)
# ---------------------------------------------------------------------------- #
# paio -- Paio library
message(STATUS "Installing PAIO data plane library")
if (FETCH_FROM_GIT)
message(STATUS "Fetching libpaio from git")
FetchContent_Declare(paio
GIT_REPOSITORY https://github.com/dsrhaslab/paio.git
GIT_TAG origin/main
)
FetchContent_MakeAvailable(paio)
target_link_libraries(padll paio)
else()
message(STATUS "Finding libpaio in local environment")
find_library(PAIO_LIBRARY paio HINTS ${PAIO_LOCAL_PATH})
target_link_libraries(padll ${PAIO_LIBRARY})
endif()
# ---------------------------------------------------------------------------- #
# spdlog -- logging library
if(${CMAKE_VERSION} VERSION_LESS "3.24.0")
FetchContent_Declare(spdlog
URL https://github.com/gabime/spdlog/archive/v1.8.1.tar.gz
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
else ()
FetchContent_Declare(spdlog
URL https://github.com/gabime/spdlog/archive/v1.8.1.tar.gz
UPDATE_COMMAND ""
INSTALL_COMMAND ""
DOWNLOAD_EXTRACT_TIMESTAMP NEW
)
endif ()
FetchContent_MakeAvailable(spdlog)
set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(padll spdlog)
# ---------------------------------------------------------------------------- #
# tests
if (PADLL_BUILD_TESTS)
enable_testing()
function(padll_test test_file executable_name)
get_filename_component(test_target_name "${executable_name}" NAME_WE)
add_executable("${test_target_name}" "")
target_sources("${test_target_name}"
PRIVATE
"${test_file}"
)
target_link_libraries("${test_target_name}" padll)
add_test(NAME "${test_target_name}" COMMAND "${test_target_name}")
endfunction(padll_test)
padll_test("tests/padll_mount_point_differentiation_test.cpp" "mountpoint_test")
padll_test("tests/padll_paio_integration_test.cpp" "stage_integration_test")
padll_test("tests/padll_simulate_macro_test.cpp" "macro_test")
padll_test("tests/padll_simulate_micro_test.cpp" "micro_test")
padll_test("tests/padll_statistics_test.cpp" "statistics_test")
padll_test("tests/padll_xoshiro_test.cpp" "xoshiro_bench")
padll_test("tests/posix/simple_test.cpp" "simple_test")
padll_test("tests/posix/hybrid_calls_test.cpp" "hybrid_test")
padll_test("tests/posix/directory_calls_test.cpp" "dir_test")
padll_test("tests/posix/extended_attributes_calls_test.cpp" "xattr_test")
endif (PADLL_BUILD_TESTS)
if (PADLL_BUILD_BENCHMARKS)
enable_testing()
function(padll_benchmarks test_file executable_name)
get_filename_component(test_target_name "${executable_name}" NAME_WE)
add_executable("${test_target_name}" "")
target_sources("${test_target_name}"
PRIVATE
"${test_file}"
)
target_link_libraries("${test_target_name}")
add_test(NAME "${test_target_name}" COMMAND "${test_target_name}")
endfunction(padll_benchmarks)
padll_benchmarks("benchmarking/padll_scalability_benchmark.cpp" "padll_scalability_bench")
endif (PADLL_BUILD_BENCHMARKS)
# ---------------------------------------------------------------------------- #
# install
if (PADLL_INSTALL)
include(GNUInstallDirs)
install(
TARGETS padll
EXPORT padllTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY include/padll TYPE INCLUDE)
endif (PADLL_INSTALL)
# ---------------------------------------------------------------------------- #