forked from westerndigitalcorporation/zenfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
137 lines (109 loc) · 6.51 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
cmake_minimum_required(VERSION 3.4)
if (NOT DEFINED AQUAFS_STANDALONE)
set(AQUAFS_STANDALONE 1)
endif ()
if (NOT DEFINED AQUAFS_EXPORT_PROMETHEUS)
set(AQUAFS_EXPORT_PROMETHEUS OFF)
endif ()
set(AQUAFS_VERSION v0.0.1-alpha)
set(aquafs_SOURCES_local "fs/fs_aquafs.cc" "fs/zbd_aquafs.cc" "fs/io_aquafs.cc" "fs/zonefs_aquafs.cc"
"fs/zbdlib_aquafs.cc"
"fs/raid/zone_raid.cc" "fs/raid/zone_raid_auto.cc" "fs/raid/zone_raid0.cc" "fs/raid/zone_raid1.cc" "fs/raid/zone_raidc.cc"
"fs/raid/zone_raid_allocator.cc"
"fs/configuration.cc")
set(aquafs_HEADERS_local "fs/fs_aquafs.h" "fs/zbd_aquafs.h" "fs/io_aquafs.h" "fs/version.h" "fs/metrics.h"
"fs/snapshot.h" "fs/filesystem_utility.h" "fs/zonefs_aquafs.h" "fs/zbdlib_aquafs.h"
"fs/raid/zone_raid.h" "fs/raid/zone_raid_auto.h" "fs/raid/zone_raid0.h" "fs/raid/zone_raid1.h" "fs/raid/zone_raidc.h"
"fs/raid/zone_raid_allocator.h"
"fs/configuration.h")
set(aquafs_LIBS_local "zbd")
if (AQUAFS_STANDALONE)
project(aquafs)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/fs/version.h "#pragma once\n#define AQUAFS_VERSION \"${AQUAFS_VERSION}\"\n")
set(aquafs_SOURCES ${aquafs_SOURCES_local})
set(aquafs_HEADERS ${aquafs_HEADERS_local})
set(aquafs_LIBS ${aquafs_LIBS_local} "gflags" "rocksdb" "uring" "zstd" "lz4" "snappy" "bz2" "z" "numa")
# file(GLOB_RECURSE port_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/port/*.cc)
# file(GLOB_RECURSE util_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/util/util/*.cc)
# file(GLOB_RECURSE test_util_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test_util/*.cc)
if (NOT AQUAFS_SKIP_LIBZBD_CHECK)
find_package(PkgConfig REQUIRED)
pkg_search_module(ZBD REQUIRED libzbd>=1.5.0)
# pkg_search_module(rocksdb REQUIRED)
find_package(gflags REQUIRED)
add_definitions(-DGFLAGS=1)
include_directories(${GFLAGS_INCLUDE_DIR})
# find_package(NUMA REQUIRED)
add_definitions(-DNUMA)
# include_directories(${NUMA_INCLUDE_DIR})
endif ()
# add_library(port STATIC ${port_SOURCES})
# add_library(util STATIC ${util_SOURCES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/util)
add_library(aaquafs STATIC ${aquafs_SOURCES} ${aquafs_HEADERS})
target_link_libraries(aaquafs ${aquafs_LIBS})
add_definitions(-DWITH_TERARKDB=1 -DOS_LINUX=1 -DROCKSDB_PLATFORM_POSIX=1)
add_executable(aquafs ${CMAKE_CURRENT_SOURCE_DIR}/util/aquafs.cc)
target_link_libraries(aquafs aaquafs)
add_executable(defconfig ${CMAKE_CURRENT_SOURCE_DIR}/util/defconfig.cc)
target_link_libraries(defconfig aaquafs)
add_executable(db_bench ${CMAKE_CURRENT_SOURCE_DIR}/util/db_bench.cc)
target_link_libraries(db_bench aaquafs)
# basic test
enable_testing()
add_test(NAME aquafs-mkfs COMMAND sudo $<TARGET_FILE:aquafs> mkfs --zbd=nullb0 --aux_path=/tmp/aux_path --force)
add_test(NAME aquafs-list COMMAND sudo $<TARGET_FILE:aquafs> list --zbd=nullb0)
add_test(NAME aquafs-mkfs-raid0 COMMAND sudo $<TARGET_FILE:aquafs> mkfs --raids=raid0:dev:nullb0,dev:nullb1 --aux_path=/tmp/aux_path --force)
add_test(NAME aquafs-mkfs-raid1 COMMAND sudo $<TARGET_FILE:aquafs> mkfs --raids=raid1:dev:nullb0,dev:nullb1 --aux_path=/tmp/aux_path --force)
add_test(NAME aquafs-db_bench COMMAND sudo $<TARGET_FILE:db_bench> --fs_uri=aquafs://dev:nullb0 --benchmarks=fillrandom --use_direct_io_for_flush_and_compaction)
else ()
set(aquafs_LIBS "zbd" PARENT_SCOPE)
set(aquafs_CMAKE_EXE_LINKER_FLAGS "-u aquafs_filesystems_reg" PARENT_SCOPE)
set(aquafs_INCLUDE_PATHS "fs" PARENT_SCOPE)
if (NOT AQUAFS_SKIP_LIBZBD_CHECK)
find_package(PkgConfig REQUIRED)
pkg_check_modules(ZBD REQUIRED libzbd>=1.5.0)
endif ()
if (AQUAFS_EXPORT_PROMETHEUS)
message(STATUS "Prometheus metrics enabled")
# pkg_check_modules(prometheus REQUIRED prometheus-cpp-pull=1.1.0)
find_package(prometheus-cpp REQUIRED)
# link_libraries(prometheus-cpp-pull)
list(APPEND aquafs_LIBS_local "prometheus-cpp-pull" "prometheus-cpp-core")
list(APPEND aquafs_SOURCES_local "fs/metrics_prometheus.cc")
list(APPEND aquafs_HEADERS_local "fs/metrics_prometheus.h")
set(aquafs_COMPILE_FLAGS -DAQUAFS_EXPORT_PROMETHEUS=1 PARENT_SCOPE)
# add_definitions(-DAQUAFS_EXPORT_PROMETHEUS=1)
endif ()
set(aquafs_HEADERS ${aquafs_HEADERS_local} PARENT_SCOPE)
set(aquafs_SOURCES ${aquafs_SOURCES_local} PARENT_SCOPE)
set(aquafs_LIBS ${aquafs_LIBS_local} PARENT_SCOPE)
# execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# RESULT_VARIABLE GENVER_RESULT
# COMMAND ./generate-version.sh)
#
# if(GENVER_RESULT AND NOT GENVER_RESULT EQUAL 0)
# message(FATAL_ERROR "Generating AquaFS version failed")
# endif()
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/fs/version.h "#pragma once\n#define AQUAFS_VERSION \"${AQUAFS_VERSION}\"\n")
add_executable(aquafs ${CMAKE_CURRENT_SOURCE_DIR}/util/aquafs.cc ${CMAKE_CURRENT_SOURCE_DIR}/util/tools/tools.cc)
target_link_libraries(aquafs rocksdb)
target_include_directories(aquafs PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(defconfig ${CMAKE_CURRENT_SOURCE_DIR}/util/defconfig.cc)
target_link_libraries(defconfig rocksdb)
target_include_directories(defconfig PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# add unit tests
file(GLOB test_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/util/unit_tests/*.cc")
foreach (test_SOURCE ${test_SOURCES})
get_filename_component(test_NAME ${test_SOURCE} NAME_WE)
add_executable(${test_NAME} ${test_SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/util/tools/tools.cc)
target_link_libraries(${test_NAME} rocksdb)
target_include_directories(${test_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# add_test(NAME ${test_NAME} COMMAND ${test_NAME})
endforeach ()
add_test(NAME aquafs-mkfs COMMAND sudo $<TARGET_FILE:aquafs> mkfs --zbd=nullb0 --aux_path=/tmp/aux_path --force)
add_test(NAME aquafs-list COMMAND sudo $<TARGET_FILE:aquafs> list --zbd=nullb0)
add_test(NAME aquafs-mkfs-raid0 COMMAND sudo $<TARGET_FILE:aquafs> mkfs --raids=raid0:dev:nullb0,dev:nullb1 --aux_path=/tmp/aux_path --force)
add_test(NAME aquafs-mkfs-raid1 COMMAND sudo $<TARGET_FILE:aquafs> mkfs --raids=raid1:dev:nullb0,dev:nullb1 --aux_path=/tmp/aux_path --force)
add_test(NAME aquafs-db_bench COMMAND sudo $<TARGET_FILE:db_bench> --fs_uri=aquafs://raid1:dev:nullb0,dev:nullb1 --benchmarks=fillrandom --use_direct_io_for_flush_and_compaction)
endif ()