This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
forked from steemit/steem
-
Notifications
You must be signed in to change notification settings - Fork 35
/
CMakeLists.txt
94 lines (80 loc) · 3.36 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
find_package(libmongoc-1.0 1.8)
if (libmongoc-1.0_FOUND)
# Golos has no direct dependencies on libmongoc but its shared libraries
# will need to be present at runtime for the C++ libraries we use:
# libbsoncxx & libmongocxx (both from github.com/mongodb/mongo-cxx-driver)
# The *.cmake package files provided by mongo-cxx-driver don't give us the
# absolute path to the libraries, which is needed whenever they are not
# installed in system-known locations. CMake requires the absolute paths
# in target_link_libraries() since we are builiding an archive and the
# link step for all executables using this archive must include the
# mongo-cxx-driver libraries libmongocxx and libbsoncxx.
find_package(libbsoncxx REQUIRED)
message(STATUS "Found bsoncxx headers: ${LIBBSONCXX_INCLUDE_DIRS}")
find_library(GOLOS_LIBBSONCXX ${LIBBSONCXX_LIBRARIES}
PATHS ${LIBBSONCXX_LIBRARY_DIRS} NO_DEFAULT_PATH)
message(STATUS "Found bsoncxx library: ${GOLOS_LIBBSONCXX}")
find_package(libmongocxx REQUIRED)
message(STATUS "Found mongocxx headers: ${LIBMONGOCXX_INCLUDE_DIRS}")
find_library(GOLOS_LIBMONGOCXX ${LIBMONGOCXX_LIBRARIES}
PATHS ${LIBMONGOCXX_LIBRARY_DIRS} NO_DEFAULT_PATH)
message(STATUS "Found mongocxx library: ${GOLOS_LIBMONGOCXX}")
set(CURRENT_TARGET mongo_db)
list(APPEND CURRENT_TARGET_HEADERS
include/golos/plugins/mongo_db/mongo_db_plugin.hpp
include/golos/plugins/mongo_db/mongo_db_writer.hpp
)
list(APPEND CURRENT_TARGET_SOURCES
mongo_db_plugin.cpp
mongo_db_writer.cpp
)
if(BUILD_SHARED_LIBRARIES)
add_library(golos_${CURRENT_TARGET} SHARED
${CURRENT_TARGET_HEADERS}
${CURRENT_TARGET_SOURCES}
)
else()
add_library(golos_${CURRENT_TARGET} STATIC
${CURRENT_TARGET_HEADERS}
${CURRENT_TARGET_SOURCES}
)
endif()
add_library(golos::${CURRENT_TARGET} ALIAS golos_${CURRENT_TARGET})
set_property(TARGET golos_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET})
target_link_libraries(
golos_${CURRENT_TARGET}
golos::json_rpc
golos_chain
golos::chain_plugin
appbase
fc
${GOLOS_LIBBSONCXX}
${GOLOS_LIBMONGOCXX}
)
target_include_directories(golos_${CURRENT_TARGET} PUBLIC "include" ${LIBMONGOCXX_INCLUDE_DIRS} ${LIBBSONCXX_INCLUDE_DIRS})
install(TARGETS
golos_${CURRENT_TARGET}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install( FILES ${HEADERS} DESTINATION "include/golos/plugins/mongo_db" )
else()
message("Could NOT find MongoDB. mongo_db_plugin with MongoDB support will not be included.")
# sudo apt-get install pkg-config libssl-dev libsasl2-dev
# wget https://github.com/mongodb/mongo-c-driver/releases/download/1.8.0/mongo-c-driver-1.8.0.tar.gz
# tar xzf mongo-c-driver-1.8.0.tar.gz
# cd mongo-c-driver-1.8.0
# ./configure --disable-automatic-init-and-cleanup --enable-static
# make
# sudo make install
#
# git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1
# cd mongo-cxx-driver/build
# cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
# sudo make EP_mnmlstc_core
# make
# sudo make install
#
# sudo apt-get install mongodb
endif()