This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathCMakeLists.txt
125 lines (105 loc) · 5.11 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
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019-2021, Intel Corporation
#
# examples/CMakeLists.txt - CMake file for building all examples along with
# the current pmemkv sources, for verification purposes.
# To build an example as a standalone application (with pmemkv from the system)
# see a CMake file in any of the subdirectories.
#
add_custom_target(examples)
# ----------------------------------------------------------------- #
## Setup examples
# ----------------------------------------------------------------- #
add_common_flag(-Wno-unused-but-set-variable)
add_common_flag(-Wno-maybe-uninitialized)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
add_dependencies(examples pmemkv)
# Add developer checks
add_cppstyle(examples ${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_basic_c/*.c
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_basic_cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_pmemobj_cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_config_c/*.c
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_open_cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_comparator_cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_comparator_c/*.c
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_transaction_cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_transaction_c/*.c
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_iterator_c/*.c
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_iterator_cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_fill_cpp/*.cpp)
add_check_whitespace(examples ${CMAKE_CURRENT_SOURCE_DIR}/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_basic_c/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_basic_cpp/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_pmemobj_cpp/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_config_c/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_open_cpp/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_comparator_cpp/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_comparator_c/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_transaction_cpp/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_transaction_c/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_iterator_c/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_iterator_cpp/*.*
${CMAKE_CURRENT_SOURCE_DIR}/pmemkv_fill_cpp/*.*)
function(add_example name)
set(srcs ${ARGN})
prepend(srcs ${CMAKE_CURRENT_SOURCE_DIR} ${srcs})
add_executable(example-${name} ${srcs})
add_dependencies(examples example-${name})
endfunction()
# ----------------------------------------------------------------- #
## Add examples (if engine used in specific example is enabled)
# ----------------------------------------------------------------- #
if(ENGINE_CMAP)
add_example(pmemkv_basic_cpp pmemkv_basic_cpp/pmemkv_basic.cpp)
target_link_libraries(example-pmemkv_basic_cpp pmemkv)
add_example(pmemkv_basic_c pmemkv_basic_c/pmemkv_basic.c)
target_link_libraries(example-pmemkv_basic_c pmemkv)
add_example(pmemkv_pmemobj_cpp pmemkv_pmemobj_cpp/pmemkv_pmemobj.cpp)
target_link_libraries(example-pmemkv_pmemobj_cpp pmemkv ${LIBPMEMOBJ++_LIBRARIES})
add_example(pmemkv_basic_config_c pmemkv_config_c/pmemkv_basic_config.c)
target_link_libraries(example-pmemkv_basic_config_c pmemkv ${LIBPMEMOBJ++_LIBRARIES})
if(BUILD_JSON_CONFIG)
add_example(pmemkv_config_c pmemkv_config_c/pmemkv_config.c)
target_link_libraries(example-pmemkv_config_c pmemkv pmemkv_json_config)
endif()
add_example(pmemkv_open_cpp pmemkv_open_cpp/pmemkv_open.cpp)
target_link_libraries(example-pmemkv_open_cpp pmemkv)
else()
message(STATUS
"Some examples use cmap engine, which is disabled, hence they are "
"not built. If you want to build them use -DENGINE_CMAP=ON option.")
endif()
if(ENGINE_CSMAP)
add_example(pmemkv_comparator_cpp pmemkv_comparator_cpp/pmemkv_comparator.cpp)
target_link_libraries(example-pmemkv_comparator_cpp pmemkv)
add_example(pmemkv_comparator_c pmemkv_comparator_c/pmemkv_comparator.c)
target_link_libraries(example-pmemkv_comparator_c pmemkv)
include(FindThreads)
if (CMAKE_USE_PTHREADS_INIT)
add_example(pmemkv_iterator_cpp pmemkv_iterator_cpp/pmemkv_iterator.cpp)
target_link_libraries(example-pmemkv_iterator_cpp pmemkv pthread)
endif()
else()
message(STATUS
"Some examples use csmap engine, which is disabled, hence they are "
"not built. If you want to build them use -DENGINE_CSMAP=ON option.")
endif()
if(ENGINE_RADIX)
add_example(pmemkv_transaction_cpp pmemkv_transaction_cpp/pmemkv_transaction.cpp)
target_link_libraries(example-pmemkv_transaction_cpp pmemkv ${LIBPMEMOBJ++_LIBRARIES})
add_example(pmemkv_transaction_c pmemkv_transaction_c/pmemkv_transaction.c)
target_link_libraries(example-pmemkv_transaction_c pmemkv ${LIBPMEMOBJ++_LIBRARIES})
add_example(pmemkv_iterator_c pmemkv_iterator_c/pmemkv_iterator.c)
target_link_libraries(example-pmemkv_iterator_c pmemkv)
else()
message(STATUS
"Some examples use radix engine, which is disabled, hence they are "
"not built. If you want to build them use -DENGINE_RADIX=ON option.")
endif()
if(NOT ENGINE_CMAP AND NOT ENGINE_CSMAP AND NOT ENGINE_RADIX)
message(WARNING "None of engines required for examples was enabled, "
"so no examples were built. See messages above for instructions.")
endif()
# Engine in this example is paremetrized at runtime
add_example(pmemkv_fill_cpp pmemkv_fill_cpp/pmemkv_fill.cpp)
target_link_libraries(example-pmemkv_fill_cpp pmemkv)