forked from alanxz/SimpleAmqpClient
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
207 lines (160 loc) · 7.23 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(SimpleAmqpClient)
# Follow all steps below in order to calculate new ABI version when updating the library
# NOTE: THIS IS UNRELATED to the actual project version
#
# 1. If the library source code has changed at all since the last update, then increment revision
# 2. If any interfaces have been added, removed, or changed since the last update, increment
# current and set revision to 0.
# 3. If any interfaces have been added since the last public release, then increment age.
# 4. If any interfaces have been removed since the last public release, then set age to 0.
set(SAC_SOVERSION_CURRENT 6)
set(SAC_SOVERSION_REVISION 0)
set(SAC_SOVERSION_AGE 4)
math(EXPR SAC_SOVERSION_MAJOR "${SAC_SOVERSION_CURRENT} - ${SAC_SOVERSION_AGE}")
math(EXPR SAC_SOVERSION_MINOR "${SAC_SOVERSION_AGE}")
math(EXPR SAC_SOVERSION_PATCH "${SAC_SOVERSION_REVISION}")
set(SAC_VERSION ${SAC_SOVERSION_MAJOR}.${SAC_SOVERSION_MINOR}.${SAC_SOVERSION_PATCH})
set(SAC_SOVERSION ${SAC_SOVERSION_MAJOR})
file(STRINGS src/SimpleAmqpClient/Version.h _API_VERSION_MAJOR REGEX "^#define SIMPLEAMQPCLIENT_VERSION_MAJOR [0-9]+$")
file(STRINGS src/SimpleAmqpClient/Version.h _API_VERSION_MINOR REGEX "^#define SIMPLEAMQPCLIENT_VERSION_MINOR [0-9]+$")
file(STRINGS src/SimpleAmqpClient/Version.h _API_VERSION_PATCH REGEX "^#define SIMPLEAMQPCLIENT_VERSION_PATCH [0-9]+$")
string(REGEX MATCH "[0-9]+" _API_VERSION_MAJOR ${_API_VERSION_MAJOR})
string(REGEX MATCH "[0-9]+" _API_VERSION_MINOR ${_API_VERSION_MINOR})
string(REGEX MATCH "[0-9]+" _API_VERSION_PATCH ${_API_VERSION_PATCH})
set(SAC_APIVERSION ${_API_VERSION_MAJOR}.${_API_VERSION_MINOR}.${_API_VERSION_PATCH})
FIND_PACKAGE(Boost 1.47.0 COMPONENTS chrono system REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
FIND_PACKAGE(Rabbitmqc REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${Rabbitmqc_INCLUDE_DIRS})
option(ENABLE_SSL_SUPPORT "Enable SSL support." ${Rabbitmqc_SSL_ENABLED})
if (ENABLE_SSL_SUPPORT)
add_definitions(-DSAC_SSL_SUPPORT_ENABLED)
endif()
if (CMAKE_GENERATOR MATCHES ".*(Make|Ninja).*"
AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE)
message(STATUS "CMAKE_BUILD_TYPE not specified. Using ${CMAKE_BUILD_TYPE} build")
endif ()
if (CMAKE_CXX_FLAGS STREQUAL ""
AND NOT DEFINED SAC_CXX_FLAGS_SET)
if (CMAKE_COMPILER_IS_GNUCXX
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "-Wall -Wextra" CACHE STRING "Flags used by the compiler during all build types." FORCE)
endif ()
set(SAC_CXX_FLAGS_SET TRUE CACHE INTERNAL "Have the SAC default compiler flags been set?")
endif ()
INCLUDE_DIRECTORIES(BEFORE src
${CMAKE_CURRENT_BINARY_DIR})
option(BUILD_SHARED_LIBS "Build SimpleAmqpClient as a shared library" ON)
if (WIN32 AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "The SimpleAmqpClient library cannot be built as a static library on Win32. Set BUILD_SHARED_LIBS=ON to get around this.")
endif()
SET(SAC_LIB_SRCS
src/SimpleAmqpClient/SimpleAmqpClient.h
src/SimpleAmqpClient/AmqpException.h
src/AmqpException.cpp
src/SimpleAmqpClient/Channel.h
src/Channel.cpp
src/SimpleAmqpClient/ChannelImpl.h
src/ChannelImpl.cpp
src/SimpleAmqpClient/BasicMessage.h
src/BasicMessage.cpp
src/SimpleAmqpClient/Util.h
src/SimpleAmqpClient/AmqpLibraryException.h
src/AmqpLibraryException.cpp
src/SimpleAmqpClient/AmqpResponseLibraryException.h
src/AmqpResponseLibraryException.cpp
src/SimpleAmqpClient/BadUriException.h
src/SimpleAmqpClient/ConnectionClosedException.h
src/SimpleAmqpClient/ConsumerTagNotFoundException.h
src/SimpleAmqpClient/Envelope.h
src/Envelope.cpp
src/SimpleAmqpClient/MessageReturnedException.h
src/MessageReturnedException.cpp
src/SimpleAmqpClient/Table.h
src/Table.cpp
src/SimpleAmqpClient/TableImpl.h
src/TableImpl.cpp
)
ADD_LIBRARY(SimpleAmqpClient ${SAC_LIB_SRCS})
TARGET_LINK_LIBRARIES(SimpleAmqpClient ${Rabbitmqc_LIBRARY} ${Boost_LIBRARIES} ${SOCKET_LIBRARY})
if (WIN32)
set_target_properties(SimpleAmqpClient PROPERTIES VERSION ${SAC_VERSION} OUTPUT_NAME SimpleAmqpClient.${SAC_SOVERSION})
else ()
set_target_properties(SimpleAmqpClient PROPERTIES VERSION ${SAC_VERSION} SOVERSION ${SAC_SOVERSION})
endif ()
#ADD_EXECUTABLE(simple_connect examples/simple_connect.cpp)
#TARGET_LINK_LIBRARIES(simple_connect SimpleAmqpClient)
#SET_TARGET_PROPERTIES(simple_connect PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
#
#ADD_EXECUTABLE(consume_with_timeout examples/consume_with_timeout.cpp)
#TARGET_LINK_LIBRARIES(consume_with_timeout SimpleAmqpClient ${Boost_LIBRARIES})
#SET_TARGET_PROPERTIES(consume_with_timeout PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
#
#ADD_EXECUTABLE(envelope_test examples/envelope_test.cpp)
#TARGET_LINK_LIBRARIES(envelope_test SimpleAmqpClient)
#SET_TARGET_PROPERTIES(envelope_test PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
#
#ADD_EXECUTABLE(basic_return_test examples/basic_return_test.cpp)
#TARGET_LINK_LIBRARIES(basic_return_test SimpleAmqpClient)
#SET_TARGET_PROPERTIES(basic_return_test PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# Some smoke tests:
option(ENABLE_TESTING "Enable smoke tests" OFF)
if (ENABLE_TESTING)
enable_testing()
add_subdirectory(third-party/gtest-1.7.0)
add_subdirectory(testing)
endif (ENABLE_TESTING)
# Documentation generation
SET(DOXYFILE_LATEX "NO")
SET(PROJECT_VERSION ${SAC_VERSION})
INCLUDE(UseDoxygen)
INSTALL(TARGETS SimpleAmqpClient
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
INSTALL(FILES
src/SimpleAmqpClient/AmqpException.h
src/SimpleAmqpClient/AmqpLibraryException.h
src/SimpleAmqpClient/AmqpResponseLibraryException.h
src/SimpleAmqpClient/BadUriException.h
src/SimpleAmqpClient/BasicMessage.h
src/SimpleAmqpClient/Channel.h
src/SimpleAmqpClient/ConnectionClosedException.h
src/SimpleAmqpClient/ConsumerCancelledException.h
src/SimpleAmqpClient/ConsumerTagNotFoundException.h
src/SimpleAmqpClient/Envelope.h
src/SimpleAmqpClient/MessageReturnedException.h
src/SimpleAmqpClient/SimpleAmqpClient.h
src/SimpleAmqpClient/Table.h
src/SimpleAmqpClient/Util.h
src/SimpleAmqpClient/Version.h
DESTINATION include/SimpleAmqpClient
)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/lib")
set(includedir "\${prefix}/include")
foreach(_lib ${Boost_LIBRARIES})
get_filename_component(_LIBPATH ${_lib} PATH)
if (NOT _LIBPATH STREQUAL _LASTLIBPATH)
set(libs_private "${libs_private} -L${_LIBPATH}")
set(_LASTLIBPATH ${_LIBPATH})
endif()
get_filename_component(_LIBNAME ${_lib} NAME_WE)
string(REGEX REPLACE "^lib" "" _LIBNAME ${_LIBNAME})
set(_LIBNAME "-l${_LIBNAME}")
set(libs_private "${libs_private} ${_LIBNAME}")
endforeach()
configure_file(libSimpleAmqpClient.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libSimpleAmqpClient.pc @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/libSimpleAmqpClient.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig
)