forked from thesamet/rpcz
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
109 lines (86 loc) · 3.14 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
cmake_minimum_required (VERSION 2.8.10)
project(rpcz)
set(RPCZ_VERSION_MAJOR 0)
set(RPCZ_VERSION_MINOR 9)
set(RPCZ_VERSION_PATCH 0)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
message("-- Build type: ${CMAKE_BUILD_TYPE}")
option(rpcz_build_tests "Build rpcz's tests." OFF)
option(rpcz_build_examples "Build rpcz's examples." OFF)
option(rpcz_enable_ipv6 "Enable IPv6 protocol." OFF)
if(MSVC)
option(rpcz_build_static "Build static library." ON)
else()
option(rpcz_build_static "Build static library." OFF)
endif()
find_package(ProtobufPlugin REQUIRED)
if(WIN32)
add_definitions(-DBOOST_ALL_NO_LIB)
add_definitions(-DBOOST_ALL_DYN_LINK)
add_definitions(-DBOOST_LIB_DIAGNOSTIC)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
# date_time is required only on Windows
find_package(Boost REQUIRED COMPONENTS thread program_options system date_time)
else()
find_package(Boost REQUIRED COMPONENTS thread program_options system)
endif()
find_package(ZeroMQ REQUIRED)
include_directories(${ZeroMQ_INCLUDE_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/src)
if(MSVC)
add_definitions("/W3 /wd4996")
set(CMAKE_DEBUG_POSTFIX "_d")
else()
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -Werror")
endif()
set(CMAKE_OSX_ARCHITECTURES x86_64)
add_subdirectory(src)
if(rpcz_build_tests)
enable_testing()
add_subdirectory(test)
endif(rpcz_build_tests)
if(rpcz_build_examples)
add_subdirectory(examples/cpp)
endif(rpcz_build_examples)
file(GLOB RPCZ_PUBLIC_HEADERS include/rpcz/*.hpp)
install(FILES ${RPCZ_PUBLIC_HEADERS} DESTINATION include/rpcz)
install(FILES ${PROJECT_BINARY_DIR}/src/rpcz/rpcz.pb.h DESTINATION include/rpcz)
###########################################################
# PACKAGE GENERATION
###########################################################
# Package target
set(CPACK_PACKAGE_NAME "rpcz")
set(CPACK_PACKAGE_VENDOR "Nadav Samet")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "RPC implementation for Protocol Buffers over ZeroMQ")
set(CPACK_PACKAGE_VERSION_MAJOR "${RPCZ_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${RPCZ_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${RPCZ_VERSION_PATCH}")
if(UNIX)
# Debian package specific config
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Philippe Hamelin")
# On recent Ubuntu versions, RPCZ may be build with either ZMQ 2 or 3
if(${ZMQ_VERSION_MAJOR} GREATER 2)
# Depends on ZMQ 3
set(CPACK_DEBIAN_ZEROMQ_DEPENDS "libzmq3")
else()
# Depends on ZMQ 2
set(CPACK_DEBIAN_ZEROMQ_DEPENDS "libzmq1")
endif()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_ZEROMQ_DEPENDS}, libprotobuf8, protobuf-compiler")
elseif(WIN32)
set(CPACK_GENERATOR "ZIP")
endif()
if(CPACK_GENERATOR)
include(CPack)
endif(CPACK_GENERATOR)