Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
73 lines (67 loc) · 2.98 KB
/
Copy pathCMakeLists.txt
File metadata and controls
73 lines (67 loc) · 2.98 KB
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
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_FLAGS "-g -Wall -Werror")
project(core)
#mongo
find_package (libmongoc-static-1.0 1.7 REQUIRED)
message ("-- mongoc found version \"${MONGOC_STATIC_VERSION}\"")
message ("-- mongoc include path \"${MONGOC_STATIC_INCLUDE_DIRS}\"")
message ("-- mongoc libraries \"${MONGOC_STATIC_LIBRARIES}\"")
# Boost
find_package(Boost 1.67.0 COMPONENTS system filesystem thread REQUIRED)
if (Boost_FOUND)
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
include_directories(${Boost_INCLUDE_DIRS})
endif ()
# pthread
find_package(Threads REQUIRED)
if (CMAKE_USE_PTHREADS_INIT)
add_definitions(-DHAVE_PTHREAD)
endif (CMAKE_USE_PTHREADS_INIT)
# Protobuf
set(PROTO_FILE_DIR ../../common)
set(PROTO_EXEC protoc)
set(PROTO_FILE_NAME message.proto)
set(GEN_DIR ./gen)
find_package(Protobuf REQUIRED)
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
file(MAKE_DIRECTORY ${GEN_DIR})
message(STATUS "Generating C++ proto stubs...")
list(APPEND PROTO_CPP_ARGS "--cpp_out=${GEN_DIR}" "--proto_path=${PROTO_FILE_DIR}" "${PROTO_FILE_NAME}")
execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} ${PROTO_CPP_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error)
message(STATUS "...done. ${output}")
message(STATUS "Generating Python proto stubs...")
list(APPEND PROTO_PYTHON_ARGS "--python_out=${GEN_DIR}" "--proto_path=${PROTO_FILE_DIR}" "${PROTO_FILE_NAME}")
execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} ${PROTO_PYTHON_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error)
message(STATUS "...done. ${output}")
file(GLOB PROTOBUF_MODELS_INCLUDES "gen/message.pb.cc")
# Building executable
add_executable(${PROJECT_NAME} src/receiver.cpp src/receiver.h ${PROTOBUF_MODELS_INCLUDES}
src/main.cpp
src/connection.h src/connection.cpp
src/server.cpp src/server.h
src/database.cpp src/database.h src/board.h src/point.h src/settings.cpp src/settings.h src/board.cpp src/point.cpp src/statistics.cpp src/statistics.h src/room.cpp src/room.h)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
if (Boost_FOUND)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif ()
if (Protobuf_FOUND)
target_link_libraries(${PROJECT_NAME} ${Protobuf_LIBRARIES})
endif()
if(libmongoc-static-1.0_FOUND)
target_include_directories (${PROJECT_NAME} PRIVATE "${MONGOC_STATIC_INCLUDE_DIRS}")
target_link_libraries (${PROJECT_NAME} "${MONGOC_STATIC_LIBRARIES}")
target_compile_definitions (${PROJECT_NAME} PRIVATE "${MONGOC_STATIC_DEFINITIONS}")
endif()