forked from RediSearch/RediSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
172 lines (128 loc) · 5.03 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
cmake_minimum_required(VERSION 3.13)
# set(CMAKE_CXX_STANDARD 20)
get_filename_component(root ${CMAKE_CURRENT_LIST_DIR} ABSOLUTE)
include(${root}/deps/readies/cmake/main)
get_filename_component(binroot ${CMAKE_CURRENT_BINARY_DIR}/.. ABSOLUTE)
#----------------------------------------------------------------------------------------------
option(BUILD_STATIC "Build a static library" OFF)
# BUILD_COORDINATOR
# BUILD_COORD_OSS
# BUILD_COORD_RLEC
option(USE_REDIS_ALLOCATOR "Use redis allocator" ON)
option(BUILD_SEARCH_UNIT_TESTS "Build unit tests" OFF)
#----------------------------------------------------------------------------------------------
project(redisearch)
if (NOT MODULE_NAME)
set(MODULE_NAME "search")
endif()
#----------------------------------------------------------------------------------------------
setup_cc_options()
# lists_from_env(S2GEOMETRY)
# set(REDISEARCH_LIBS ${S2GEOMETRY})
# ugly hack for cpu_features::list_cpu_features coming from VecSim
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${CMAKE_LD_FLAGS}")
add_compile_definitions(
"REDISEARCH_MODULE_NAME=\"${MODULE_NAME}\""
"GIT_VERSPEC=\"${GIT_VERSPEC}\""
"GIT_SHA=\"${GIT_SHA}\""
REDISMODULE_SDK_RLEC
_GNU_SOURCE)
if (USE_REDIS_ALLOCATOR)
add_compile_definitions(REDIS_MODULE_TARGET)
endif()
#----------------------------------------------------------------------------------------------
include_directories(
${root}/src
${root}/deps
${root}/deps/RedisModulesSDK
${root}/deps/VectorSimilarity/src
# ${root}/deps/s2geometry/src
${BOOST_DIR}
${root})
add_subdirectory(deps/rmutil)
add_subdirectory(deps/friso)
add_subdirectory(deps/snowball)
add_subdirectory(deps/phonetics)
option(VECSIM_STATIC "Build as static library" ON)
option(VECSIM_BUILD_TESTS "Build vecsim tests" OFF)
add_subdirectory(deps/VectorSimilarity)
add_subdirectory(src/geometry)
#----------------------------------------------------------------------------------------------
file(GLOB SOURCES
"src/*.c"
"src/aggregate/*.c"
"src/aggregate/expr/*.c"
"src/aggregate/functions/*.c"
"src/aggregate/reducers/*.c"
"src/ext/*.c"
"src/hll/*.c"
"src/query_parser/v1/*.c"
"src/query_parser/v2/*.c"
"src/util/*.c"
"src/trie/*.c"
"src/info/*.c"
"deps/cndict/cndict_data.c"
"deps/libnu/*.c"
"deps/miniz/*.c"
"deps/base64/*.c"
"deps/thpool/*.c"
"deps/triemap/*.c"
"deps/wildcard/*.c"
"deps/geohash/*.c")
add_library(rscore OBJECT ${SOURCES})
set(FINAL_OBJECTS
$<TARGET_OBJECTS:rscore>
$<TARGET_OBJECTS:rmutil>
$<TARGET_OBJECTS:friso>
$<TARGET_OBJECTS:snowball>
$<TARGET_OBJECTS:metaphone>)
#----------------------------------------------------------------------------------------------
if (BUILD_COORDINATOR)
if (BUILD_COORD_OSS)
add_library(redisearch-oss STATIC ${SOURCES} ${FINAL_OBJECTS} src/module-init/module-init.c coord/src/rmr/reply.c)
target_compile_definitions(redisearch-oss PRIVATE
RS_NO_ONLOAD
RS_NO_RMAPI
RS_CLUSTER_OSS)
elseif (BUILD_COORD_RLEC)
add_library(redisearch-enterprise STATIC ${SOURCES} ${FINAL_OBJECTS} src/module-init/module-init.c coord/src/rmr/reply.c)
target_compile_definitions(redisearch-enterprise PRIVATE
RS_NO_ONLOAD
RS_NO_RMAPI
RS_CLUSTER_ENTERPRISE)
endif()
elseif (BUILD_STATIC)
add_library(redisearch-static STATIC ${FINAL_OBJECTS} src/module-init/module-init.c)
target_compile_definitions(redisearch-static PRIVATE
RS_NO_ONLOAD
RS_NO_RMAPI)
add_library(redisearch SHARED ${FINAL_OBJECTS} src/module-init/module-init.c)
set_target_properties(redisearch PROPERTIES LINKER_LANGUAGE CXX)
setup_shared_object_target(redisearch "")
target_link_libraries(redisearch redisearch-geometry VectorSimilarity ${REDISEARCH_LIBS} ${CMAKE_LD_LIBS})
set(TEST_MODULE "redisearch-static")
set(TEST_MODULE_SO $<TARGET_FILE:redisearch>)
else() # OSS RediSearch
add_library(redisearch SHARED ${FINAL_OBJECTS} src/module-init/module-init.c)
set_target_properties(redisearch PROPERTIES LINKER_LANGUAGE CXX)
setup_shared_object_target(redisearch "")
target_link_libraries(redisearch redisearch-geometry VectorSimilarity ${REDISEARCH_LIBS} ${CMAKE_LD_LIBS})
extract_debug_symbols(redisearch)
add_dependencies(redisearch VectorSimilarity)
endif()
#----------------------------------------------------------------------------------------------
if (BUILD_COORDINATOR)
set(BUILD_SEARCH_UNIT_TESTS OFF)
endif()
if (BUILD_SEARCH_UNIT_TESTS AND NOT BUILD_COORDINATOR AND NOT BUILD_STATIC)
set(BUILD_GTEST ON CACHE BOOL "enable gtest" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "disable gmock" FORCE)
add_subdirectory(deps/googletest)
add_subdirectory(tests/cpptests)
add_subdirectory(tests/ctests)
add_subdirectory(tests/c_utils)
add_subdirectory(tests/ctests/ext-example example_extension)
if (ENABLE_REDIS_MOCK)
add_subdirectory(tests/cpptests/redismock)
endif()
endif()