-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
158 lines (130 loc) · 5.2 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
cmake_minimum_required(VERSION 3.18.2)
project(GradidoNode C CXX)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
message("runtime output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
IF(WIN32)
set(CMAKE_CXX_FLAGS "/MP /EHsc /std:c++20")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
ELSE()
SET(CMAKE_CXX_FLAGS "-std=c++20" )
ENDIF()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF)
set(INSTALL_BINDIR "bin")
set(INSTALL_PLUGINDIR "bin")
# needed for protopuf
add_definitions(-DNOMINMAX)
include_directories(
"dependencies"
"dependencies/jsonrpcpp/include"
"dependencies/rapidjson/include"
"dependencies/gradido_blockchain"
"dependencies/gradido_blockchain/include"
"dependencies/gradido_blockchain/build"
"dependencies/gradido_blockchain/dependencies"
"dependencies/gradido_blockchain/dependencies/date/include"
"dependencies/gradido_blockchain/dependencies/magic_enum/include"
"dependencies/gradido_blockchain/dependencies/protopuf/include"
"dependencies/paho.mqtt.c/src"
#"dependencies/googletest/googletest/include"
#"dependencies/leveldb/third_party/googletest/googlemock/include"
)
FILE(GLOB BLOCKCHAIN "src/blockchain/*.h" "src/blockchain/*.cpp")
FILE(GLOB CACHE_SRC "src/cache/*.h" "src/cache/*.cpp")
FILE(GLOB CONTAINER, "src/container/*.h" "src/container/*.cpp")
FILE(GLOB CONTROLLER "src/controller/*.cpp" "src/controller/*.h")
FILE(GLOB CLIENT "src/client/*.cpp" "src/client/*.h")
FILE(GLOB IOTA "src/iota/*.cpp" "src/iota/*.h")
FILE(GLOB SERVER "src/server/*.h" "src/server/*.cpp")
FILE(GLOB SERVER_JSON_RPC "src/server/json-rpc/*.h" "src/server/json-rpc/*.cpp")
FILE(GLOB LIB_SRC "src/lib/*.h" "src/lib/*.cpp" "src/lib/*.c")
FILE(GLOB MODEL "src/model/*.h" "src/model/*.cpp")
FILE(GLOB MODEL_APOLLO "src/model/Apollo/*.h" "src/model/Apollo/*.cpp")
FILE(GLOB MODEL_FILES "src/model/files/*.h" "src/model/files/*.cpp")
FILE(GLOB MODEL_JSON "src/model/json/*.h" "src/model/json/*.cpp")
FILE(GLOB SINGLETON_MANAGER "src/SingletonManager/*.h" "src/SingletonManager/*.cpp")
FILE(GLOB TASK "src/task/*.cpp" "src/task/*.h")
FILE(GLOB VIEW "src/view/*.h" "src/view/*.cpp")
FILE(GLOB MAIN "src/*.cpp" "src/*.c" "src/*.h")
SET(LOCAL_SRCS
${BLOCKCHAIN}
${CACHE_SRC}
${CONTAINER} ${CONTROLLER} ${CLIENT} ${IOTA}
${SERVER} ${SERVER_JSON_RPC}
${LIB_SRC}
${MODEL} ${MODEL_APOLLO} ${MODEL_FILES} ${MODEL_JSON}
${SINGLETON_MANAGER}
${TASK} ${VIEW}
${MAIN}
)
#aux_source_directory("src/cpp" LOCAL_SRCS)
if(MSVC)
# src
source_group("blockchain" FILES ${BLOCKCHAIN})
source_group("cache" FILES ${CACHE_SRC})
source_group("container" FILES ${CONTAINER})
source_group("client" FILES ${CLIENT})
source_group("controller" FILES ${CONTROLLER})
source_group("iota" FILES ${IOTA})
source_group("Json-rpc-Interface" FILES ${JSONRPCInterface})
source_group("lib" FILES ${LIB_SRC})
source_group("model\\Apollo" FILES ${MODEL_APOLLO})
source_group("model\\files" FILES ${MODEL_FILES})
source_group("model\\json" FILES ${MODEL_JSON})
source_group("model" FILES ${MODEL})
source_group("server\\json-rpc" FILES ${SERVER_JSON_RPC})
source_group("server" FILES ${SERVER})
source_group("SingletonManager" FILES ${SINGLETON_MANAGER})
source_group("task" FILES ${TASK})
endif(MSVC)
############################## add dependencies #########################################
add_subdirectory("dependencies/gradido_blockchain")
SET(GradidoBlockchain_BINARY_DIR ${GradidoNode_BINARY_DIR})
add_subdirectory("dependencies/jsonrpcpp")
option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" OFF)
add_subdirectory("dependencies/leveldb")
#add_subdirectory("dependencies/googletest")
############################## mqtt client ############################################
add_subdirectory("dependencies/paho.mqtt.c")
if(WIN32)
find_package(libsodium REQUIRED)
include_directories(${libsodium_INCLUDE_DIR})
else()
#find_package(Sodium REQUIRED)
endif()
############################## find protobuf #########################################
#add_subdirectory(dependencies/protobuf/cmake)
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# prevent problems with two libs including googletest
#option(protobuf_BUILD_TESTS "Build tests" OFF)
#message("binary dir: ${CMAKE_BINARY_DIR}")
#add_subdirectory(dependencies/gradido_blockchain/dependencies/protobuf)
if(NOT BUILD_SHARED_LIBS)
#option(protobuf_BUILD_TESTS "Build tests" OFF)
#add_subdirectory("dependencies/gradido_blockchain/dependencies/protobuf/cmake")
endif()
add_executable(GradidoNode ${LOCAL_SRCS})
#SUBDIRS("src/test")
target_link_libraries(GradidoNode leveldb GradidoBlockchain paho-mqtt3a)
if(WIN32)
target_link_libraries(GradidoNode optimized Shlwapi)
target_link_libraries(GradidoNode debug Shlwapi)
target_link_libraries(GradidoNode libsodium::libsodium)
else()
target_link_libraries(GradidoNode sodium)
endif()
IF(WIN32)
add_custom_command(TARGET GradidoNode POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:GradidoNode> $<TARGET_FILE_DIR:GradidoNode>
COMMAND_EXPAND_LISTS
)
ENDIF()
# install
if(UNIX)
install(TARGETS GradidoNode RUNTIME DESTINATION /usr/local/bin)
endif(UNIX)
# add test
#include(CTest)
#add_subdirectory(test)