forked from splunk/pion
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
174 lines (141 loc) · 5.35 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# ---------------------------------------------------------------------
# pion: a Boost C++ framework for building lightweight HTTP interfaces
# ---------------------------------------------------------------------
# Copyright (C) 2013 Splunk Inc. (https://github.com/splunk/pion)
#
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt
# ---------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
set(PROJECT_NAME pion_solution)
project(${PROJECT_NAME} CXX C)
#-------------------------------------------------
# prepare folders var's
#-------------------------------------------------
# src root path
set(PION_SRC_ROOT ${PROJECT_SOURCE_DIR} CACHE PATH "Pion source root")
# binary output by default
set(COMMON_BIN_PATH ${CMAKE_BINARY_DIR}/Bin)
set(LIBRARY_OUTPUT_PATH ${COMMON_BIN_PATH}/${CMAKE_BUILD_TYPE})
set(EXECUTABLE_OUTPUT_PATH ${COMMON_BIN_PATH}/${CMAKE_BUILD_TYPE})
# set where to find additional cmake modules if any
set(CMAKE_MODULE_PATH ${PION_SRC_ROOT}/cmake ${CMAKE_MODULE_PATH})
include(PionUtils)
enforce_out_of_source("${PROJECT_NAME} required out-of-source build. Use 'cmake <path to source>'")
pion_get_version("${PION_SRC_ROOT}" PION_V_MAJOR PION_V_MINOR PION_V_PATCH)
pion_update_compilation_opts()
set(PION_VERSION "${PION_V_MAJOR}.${PION_V_MINOR}.${PION_V_PATCH}" CACHE STRING "Pion version" FORCE)
message(">>> Building Pion version: ${PION_VERSION}")
message(">>> EXECUTABLE_OUTPUT_PATH = ${EXECUTABLE_OUTPUT_PATH}")
#----------------------------------------------------------
# Configuration options block
#----------------------------------------------------------
# general
option(BUILD_SHARED_LIBS "Build Pion as shared library" ON)
option(BUILD_SPDY "Enable SPDY" OFF)
option(BUILD_UT "Enable Unit test" OFF)
# utils
option(BUILD_PIOND "Enable piond" ON)
option(BUILD_HELLOSERVER "Enable helloserver" ON)
# services
option(BUILD_ALLOWNOTHINGSERVICE "Enable AllowNothingService" ON)
option(BUILD_COOKIESERVICE "Enable CookieService" ON)
option(BUILD_ECHOSERVICE "Enable EchoService" ON)
option(BUILD_FILESERVICE "Enable FileService" ON)
option(BUILD_HELLOSERVICE "Enable HelloService" ON)
option(BUILD_LOGSERVICE "Enable LogService" ON)
# logging
option(USE_LOG4CPLUS "Use log4cplus" OFF)
option(USE_LOG4CXX "Use log4cxx" OFF)
option(USE_LOG4CPP "Use log4cpp" OFF)
option(DISABLE_LOGGING "Disable logging" ON)
#----------------------------------------------------------
# cleanup prefix lib for Unix-like OSes
set(CMAKE_SHARED_MODULE_PREFIX)
# install target to this folder by default
set(PION_BINARY_DIR ${PION_SRC_ROOT}/bin)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PION_BINARY_DIR}" CACHE PATH "default install path" FORCE)
endif()
# make include globaly visible
set(PROJECT_WIDE_INCLUDE ${PION_SRC_ROOT}/include)
include_directories(${PROJECT_WIDE_INCLUDE})
find_package(Threads REQUIRED)
# TODO: need to handle this with option
set(Boost_USE_MULTITHREADED ON)
#set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS thread system filesystem regex unit_test_framework REQUIRED)
if (Boost_FOUND)
# disable autolinking feature
add_definitions(-DBOOST_ALL_NO_LIB)
include_directories(${Boost_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Boost >= 1.35 required to build Pion")
endif()
include(PionConfigure)
find_package(ZLIB)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
set(PION_HAVE_ZLIB 1)
else()
if (BUILD_SPDY)
message(FATAL_ERROR "zlib is mandatory required for SPDY support")
endif()
endif()
find_package(BZip2)
if(BZIP2_FOUND)
include_directories(${BZIP2_INCLUDE_DIR})
set(PION_HAVE_BZLIB 1)
endif()
find_package(OpenSSL)
if(OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
set(PION_HAVE_SSL 1)
endif()
if(USE_LOG4CPLUS)
set(Log4Cplus_USE_STATIC_LIBS 1)
find_package(Log4cplus)
if (LOG4CPLUS_FOUND)
include_directories(${LOG4CPLUS_INCLUDE_DIR})
set(PION_USE_LOG4CPLUS 1)
endif()
endif()
if(USE_LOG4CXX)
message(FATAL_ERROR "log4cxx not supported")
# TODO: find package and set(PION_USE_LOG4CXX 1)
endif()
if(USE_LOG4CPP)
message(FATAL_ERROR "log4cpp not supported")
# TODO: find package and set(PION_USE_LOG4CPP 1)
endif()
if (DISABLE_LOGGING)
set(PION_DISABLE_LOGGING 1)
endif()
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${PROJECT_SOURCE_DIR}/doc/Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()
configure_file(${PION_SRC_ROOT}/cmake/config.hpp.cmake ${COMMON_BIN_PATH}/pion/config.hpp)
include_directories(${COMMON_BIN_PATH})
# TODO: handle #pragma comment, which is hardcoded in config.hpp
# need to generate config.hpp by ourselfs
add_definitions(-DPION_CMAKE_BUILD)
if(NOT BUILD_SHARED_LIBS)
add_definitions(-DPION_STATIC_LINKING)
endif()
#-------------------------------------------------
# enable TDD
#-------------------------------------------------
if(BUILD_UT)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif()
# here we add submodules
add_subdirectory(src)
add_subdirectory(services)
add_subdirectory(utils)
install(DIRECTORY ${PION_SRC_ROOT}/include/ DESTINATION include FILES_MATCHING PATTERN "*.hpp")
install(FILES ${COMMON_BIN_PATH}/pion/config.hpp DESTINATION include/pion/)