forked from couchbase/indexing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
148 lines (125 loc) · 5.67 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
CMAKE_MINIMUM_REQUIRED (VERSION 3.13)
PROJECT (indexing)
INCLUDE (FindCouchbaseGo)
INCLUDE (FindCouchbaseJemalloc)
INCLUDE (FindCouchbaseCurl)
INCLUDE (FindCouchbaseGrpc)
IF (BUILD_ENTERPRISE)
MESSAGE(STATUS "Building EE edition of GSI")
SET (TAGS "jemalloc")
ELSE (BUILD_ENTERPRISE)
MESSAGE(STATUS "Building CE edition of GSI")
SET (TAGS "jemalloc community")
ENDIF (BUILD_ENTERPRISE)
SET (LDFLAGS)
IF (APPLE)
# On macOS, we must use -rpath to locate libraries
# TODO: Remove debug info stripping (-s) added to allow 1.7.6 to work on macOS
SET (LDFLAGS "-s -extldflags '-Wl,-rpath,@executable_path/../lib'")
ENDIF ()
IF (WIN32)
if("${MSVC_VERSION}" LESS 1910)
SET (LDFLAGS "${LDFLAGS} -linkmode internal")
endif()
ENDIF ()
GET_FILENAME_COMPONENT (CURL_LIBRARY_DIR "${CURL_LIBRARIES}" DIRECTORY)
GET_FILENAME_COMPONENT (JEMALLOC_LIB_DIR ${JEMALLOC_LIBRARIES} DIRECTORY)
SET(CGO_INCLUDE_DIRS "${FORESTDB_INCLUDE_DIR};${sigar_SOURCE_DIR}/include;${Platform_SOURCE_DIR}/include;${CURL_INCLUDE_DIR}")
SET(CGO_LIBRARY_DIRS "${FORESTDB_LIBRARY_DIR};${sigar_BINARY_DIR}/src;${Platform_BINARY_DIR};${CURL_LIBRARY_DIR}")
IF(NOT JEMALLOC_FOUND)
MESSAGE (FATAL_ERROR "GSI requires jemalloc normally, but it was not found")
ENDIF(NOT JEMALLOC_FOUND)
SET (ENV{CGO_CFLAGS} "$ENV{CGO_CFLAGS} -DJEMALLOC=1")
SET (CGO_INCLUDE_DIRS "${CGO_INCLUDE_DIRS};${JEMALLOC_INCLUDE_DIR}")
SET (CGO_LIBRARY_DIRS "${CGO_LIBRARY_DIRS};${JEMALLOC_LIB_DIR}")
# NOTE: Everytime a new .proto file is added, add it to the right list
SET (DATA_PROTO_FILES "${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/data/mutation.proto")
SET (PROJECTOR_PROTO_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector/common.proto"
"${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector/index.proto"
"${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector/partn_key.proto"
"${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector/partn_single.proto"
"${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector/partn_tp.proto"
"${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector/projector.proto")
SET (QUERY_PROTO_FILES "${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/query/query.proto")
# Compute corresponding .pb.go files
STRING (REPLACE ".proto" ".pb.go" DATA_PBGO_FILES "${DATA_PROTO_FILES}")
STRING (REPLACE ".proto" ".pb.go" PROJECTOR_PBGO_FILES "${PROJECTOR_PROTO_FILES}")
STRING (REPLACE ".proto" ".pb.go" QUERY_PBGO_FILES "${QUERY_PROTO_FILES}")
ADD_CUSTOM_COMMAND(
OUTPUT ${DATA_PBGO_FILES}
COMMAND ${PROTOC} ARGS -I ${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/data
--go_out=${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/data
--plugin=protoc-gen-go=${PROTOC_GEN_GO_EXE}
${DATA_PROTO_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DEPENDS ${DATA_PROTO_FILES}
COMMENT "Generating protobuf/data autogenerated files")
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECTOR_PBGO_FILES}
COMMAND ${PROTOC} ARGS -I ${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector
--go_out=${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/projector
--plugin=protoc-gen-go=${PROTOC_GEN_GO_EXE}
${PROJECTOR_PROTO_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DEPENDS ${PROJECTOR_PROTO_FILES}
COMMENT "Generating protobuf/projector autogenerated files")
ADD_CUSTOM_COMMAND(
OUTPUT ${QUERY_PBGO_FILES}
COMMAND ${PROTOC} ARGS -I ${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/query
--go_out=${CMAKE_CURRENT_SOURCE_DIR}/secondary/protobuf/query
--plugin=protoc-gen-go=${PROTOC_GEN_GO_EXE}
${QUERY_PROTO_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DEPENDS ${QUERY_PROTO_FILES}
COMMENT "Generating protobuf/query autogenerated files")
ADD_CUSTOM_TARGET(proto-generated DEPENDS
${DATA_PBGO_FILES}
${PROJECTOR_PBGO_FILES}
${QUERY_PBGO_FILES}
)
GoInstall (TARGET indexer PACKAGE github.com/couchbase/indexing/secondary/cmd/indexer
GOPATH "${PROJECT_SOURCE_DIR}/../../../.." "${GODEPSDIR}"
DEPENDS forestdb
CGO_INCLUDE_DIRS "${CGO_INCLUDE_DIRS}"
CGO_LIBRARY_DIRS "${CGO_LIBRARY_DIRS}"
GOTAGS "${TAGS}"
LDFLAGS "${LDFLAGS}"
INSTALL_PATH bin OUTPUT indexer
GOVERSION 1.16.5)
ADD_DEPENDENCIES(indexer sigar forestdb platform)
ADD_DEPENDENCIES(indexer proto-generated n1ql-yacc)
GoInstall (TARGET projector PACKAGE github.com/couchbase/indexing/secondary/cmd/projector
GOPATH "${PROJECT_SOURCE_DIR}/../../../.." "${GODEPSDIR}"
CGO_INCLUDE_DIRS "${CGO_INCLUDE_DIRS}"
CGO_LIBRARY_DIRS "${CGO_LIBRARY_DIRS}"
GOTAGS "${TAGS}"
LDFLAGS "${LDFLAGS}"
INSTALL_PATH bin
GOVERSION 1.16.5)
ADD_DEPENDENCIES(projector proto-generated)
GoInstall (TARGET cbindex PACKAGE github.com/couchbase/indexing/secondary/cmd/cbindex
GOPATH "${PROJECT_SOURCE_DIR}/../../../.." "${GODEPSDIR}"
GOTAGS "${TAGS}"
CGO_INCLUDE_DIRS "${CGO_INCLUDE_DIRS}"
CGO_LIBRARY_DIRS "${CGO_LIBRARY_DIRS}"
LDFLAGS "${LDFLAGS}"
INSTALL_PATH bin
GOVERSION 1.13.7)
GoInstall (TARGET cbindexperf PACKAGE github.com/couchbase/indexing/secondary/cmd/cbindexperf
GOPATH "${PROJECT_SOURCE_DIR}/../../../.." "${GODEPSDIR}"
CGO_INCLUDE_DIRS "${CGO_INCLUDE_DIRS}"
CGO_LIBRARY_DIRS "${CGO_LIBRARY_DIRS}"
GOTAGS "${TAGS}"
LDFLAGS "${LDFLAGS}"
INSTALL_PATH bin
GOVERSION 1.13.7)
GoInstall (TARGET cbindexplan PACKAGE github.com/couchbase/indexing/secondary/cmd/cbindexplan
GOPATH "${PROJECT_SOURCE_DIR}/../../../.." "${GODEPSDIR}"
DEPENDS forestdb
CGO_INCLUDE_DIRS "${CGO_INCLUDE_DIRS}"
CGO_LIBRARY_DIRS "${CGO_LIBRARY_DIRS}"
GOTAGS "${TAGS}"
LDFLAGS "${LDFLAGS}"
INSTALL_PATH bin OUTPUT cbindexplan
GOVERSION 1.13.7)