forked from Tencent/wwsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (48 loc) · 2.7 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
cmake_minimum_required(VERSION 2.8.12)
project(wwsearch)
option(WITH_ROCKSDB "build with rocksdb" ON)
option(WITH_SNAPPY "build with snappy" ON)
option(WITH_TESTS "build with ut" OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
set(CMAKE_COMMON_FLAGS "-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -fno-builtin-memcmp -DZLIB -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -march=native -DHAVE_SSE42 -DHAVE_PCLMUL -DROCKSDB_SUPPORT_THREAD_LOCAL -DWITH_TESTS=OFF")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_FLAGS} -lpthread -lrt -lz -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_FLAGS} -lpthread -std=c++11 -lrt -lz -g")
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl -lrt")
#set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static-libgcc")
set(WWSEARCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# add search path for build rocksdb
set(CMAKE_INCLUDE_PATH "${WWSEARCH_DIR}/deps/snappy/include")
set(CMAKE_LIBRARY_PATH "${WWSEARCH_DIR}/deps/snappy/lib")
add_subdirectory(${WWSEARCH_DIR}/deps/rocksdb)
add_subdirectory(${WWSEARCH_DIR}/deps/tokenizer)
link_libraries(rocksdb)
link_libraries(tokenizer)
link_libraries(gtest)
include_directories(
${WWSEARCH_DIR}
${WWSEARCH_DIR}/include
${WWSEARCH_DIR}/deps/rocksdb/
${WWSEARCH_DIR}/deps/rocksdb/include
${WWSEARCH_DIR}/deps/rocksdb/third-party/gtest-1.7.0/fused-src
${WWSEARCH_DIR}/deps/tokenizer/include
${WWSEARCH_DIR}/unittest
)
file(GLOB WWSEARCH_SRC_DIR ./src/*.cpp ./include/*.cc)
ADD_LIBRARY(wwsearch ${WWSEARCH_SRC_DIR})
include_directories(${WWSEARCH_DIR}/deps/protobuf/include/)
FIND_LIBRARY(PROTOBUF_LIB NAMES libprotobuf.a HINTS ${WWSEARCH_DIR}/deps/protobuf/lib NO_DEFAULT_PATH)
#link_libraries(protobuf)
include_directories(${WWSEARCH_DIR}/deps/snappy/include)
FIND_LIBRARY(SNAPPY_LIB NAMES libsnappy.a HINTS ${WWSEARCH_DIR}/deps/snappy/lib NO_DEFAULT_PATH)
target_link_libraries(wwsearch rocksdb tokenizer -Lprotobuf ${PROTOBUF_LIB} -Lsnappy ${SNAPPY_LIB})
file(GLOB WWSEARCH_UT_DIR ./unittest/*.cpp)
add_executable(wwsearch_example example/example.cpp)
target_link_libraries(wwsearch_example wwsearch)
include_directories(${WWSEARCH_DIR}/benchmark)
file(GLOB WWSEARCH_BEN_DIR ./benchmark/*.cpp)
add_executable(wwsearch_ben ${WWSEARCH_BEN_DIR})
target_link_libraries(wwsearch_ben wwsearch)
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_FLAGS} -lpthread -lrt -lz -g -Dprivate=public")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_FLAGS} -lpthread -std=c++11 -lrt -lz -g -Dprivate=public")
add_executable(wwsearch_ut ${WWSEARCH_UT_DIR})
target_link_libraries(wwsearch_ut wwsearch gtest)