-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
66 lines (55 loc) · 2.4 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
######################
# PROJECT SETUP
######################
cmake_minimum_required(VERSION 2.8)
project(Chord)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_INCLUDE_CURRENT_DIR on)
set(CMAKE_BUILD_TYPE Debug)
######################
# PROTOBUF
######################
file(GLOB PROTOBUF_C_CHORD_MESSAGES "src/*.proto")
file(GLOB PROTOBUF_C_FILE_CLIENT_MESSAGES "file_client/*.proto")
find_package(ProtobufC REQUIRED)
include_directories(${PROTOBUF_C_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("include/")
include_directories("src/")
PROTOBUF_C_GENERATE_C(PROTO_C_CHORD_SRCS PROTO_C_CHORD_HDRS ${PROTOBUF_C_CHORD_MESSAGES})
PROTOBUF_C_GENERATE_C(PROTO_C_CLIENT_SRCS PROTO_C_CLIENT_HDRS ${PROTOBUF_C_FILE_CLIENT_MESSAGES})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/chord/messages.pb-c.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/messages.pb-c.h ${CMAKE_CURRENT_SOURCE_DIR}/include/chord/messages.pb-c.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/messages.pb-c.h)
######################
# PROJECT SOURCES
######################
file(GLOB lib_sources "src/*.c" "src/*.h" "include/*.h" "src/logger/*.c" "src/logger/*.h")
list(APPEND lib_sources ${PROTO_C_CHORD_SRCS} ${PROTO_C_CHORD_HDRS})
######################
# LIBRARIES
######################
find_package(OpenSSL)
include_directories(${OPENSSL_INCLUDE_DIR})
set(CMAKE_C_FLAGS "-std=c99 -Wall -Wno-format-security -ggdb -fdump-rtl-expand -fvisibility=hidden -D_GNU_SOURCE")
find_package(LibEvent)
include_directories(${LIBEVENT_INCLUDE_DIR})
add_library(chord SHARED ${lib_sources})
target_link_libraries(chord ${OPENSSL_LIBRARIES} ${LIBEVENT_LIBRARIES} ${PROTOBUF_C_LIBRARY} dl m confuse)
######################
# SIMPLE CLIENT
######################
file(GLOB simple_client_sources "simple_client/*.c" "simple_client/*.h")
add_executable(simple_client ${simple_client_sources})
target_link_libraries(simple_client chord)
target_link_libraries(simple_client pthread)
######################
# FILE CLIENT
######################
file(GLOB file_client_sources "file_client/*.cpp" "file_client/*.h")
list(APPEND file_client_sources ${PROTO_C_CLIENT_SRCS} ${PROTO_C_CLIENT_HDRS})
add_executable(file_client ${file_client_sources})
target_link_libraries(file_client chord)
target_link_libraries(file_client udt)
target_link_libraries(file_client pthread)