| 1 |
# |
| 2 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
# or more contributor license agreements. See the NOTICE file |
| 4 |
# distributed with this work for additional information |
| 5 |
# regarding copyright ownership. The ASF licenses this file |
| 6 |
# to you under the Apache License, Version 2.0 (the |
| 7 |
# "License"); you may not use this file except in compliance |
| 8 |
# with the License. You may obtain a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, |
| 13 |
# software distributed under the License is distributed on an |
| 14 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
# KIND, either express or implied. See the License for the |
| 16 |
# specific language governing permissions and limitations |
| 17 |
# under the License. |
| 18 |
# |
| 19 |
|
| 20 |
include (versions.cmake) |
| 21 |
|
| 22 |
if(WIN32 AND NOT CYGWIN) |
| 23 |
# linking against Windows native libraries, including mingw |
| 24 |
set (PN_WINAPI TRUE) |
| 25 |
endif(WIN32 AND NOT CYGWIN) |
| 26 |
|
| 27 |
set(ssl_impl, none) |
| 28 |
if(PN_WINAPI) |
| 29 |
set(ssl_impl schannel) |
| 30 |
set(ssl_providers "'none','schannel','openssl'") |
| 31 |
else(PN_WINAPI) |
| 32 |
if (OPENSSL_FOUND AND Threads_FOUND) |
| 33 |
set(ssl_impl openssl) |
| 34 |
endif () |
| 35 |
set(ssl_providers "'none','openssl'") |
| 36 |
endif(PN_WINAPI) |
| 37 |
set(SSL_IMPL ${ssl_impl} CACHE STRING "Library to use for SSL/TLS support. Valid values: ${ssl_providers}") |
| 38 |
|
| 39 |
set(sasl_providers cyrus none) |
| 40 |
if (CyrusSASL_FOUND AND Threads_FOUND) |
| 41 |
set (sasl_impl cyrus) |
| 42 |
else () |
| 43 |
set (sasl_impl none) |
| 44 |
endif () |
| 45 |
set(SASL_IMPL ${sasl_impl} CACHE STRING "Library to use for SASL support. Valid values: ${sasl_providers}") |
| 46 |
|
| 47 |
configure_file ( |
| 48 |
"${CMAKE_CURRENT_SOURCE_DIR}/include/proton/version.h.in" |
| 49 |
"${CMAKE_CURRENT_BINARY_DIR}/include/proton/version.h" |
| 50 |
) |
| 51 |
|
| 52 |
file (GLOB headers "include/proton/*.[hi]") |
| 53 |
|
| 54 |
foreach (sfile ${headers}) |
| 55 |
file (RELATIVE_PATH rfile ${CMAKE_CURRENT_SOURCE_DIR} ${sfile}) |
| 56 |
configure_file (${sfile} ${CMAKE_CURRENT_BINARY_DIR}/${rfile} COPYONLY) |
| 57 |
endforeach () |
| 58 |
|
| 59 |
include_directories ( |
| 60 |
"${CMAKE_CURRENT_SOURCE_DIR}/include" |
| 61 |
"${CMAKE_CURRENT_SOURCE_DIR}/src" |
| 62 |
${PN_C_INCLUDE_DIR} |
| 63 |
"${CMAKE_CURRENT_BINARY_DIR}/src" |
| 64 |
) |
| 65 |
|
| 66 |
add_custom_command ( |
| 67 |
OUTPUT |
| 68 |
${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h |
| 69 |
COMMAND |
| 70 |
${PN_ENV_SCRIPT} PYTHONPATH=${CMAKE_SOURCE_DIR}/tools/python ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/encodings.h.py > ${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h |
| 71 |
DEPENDS |
| 72 |
${CMAKE_CURRENT_SOURCE_DIR}/src/encodings.h.py |
| 73 |
) |
| 74 |
|
| 75 |
add_custom_command ( |
| 76 |
OUTPUT |
| 77 |
${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h |
| 78 |
COMMAND |
| 79 |
${PN_ENV_SCRIPT} PYTHONPATH=${CMAKE_SOURCE_DIR}/tools/python ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py > ${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h |
| 80 |
DEPENDS |
| 81 |
${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py |
| 82 |
) |
| 83 |
|
| 84 |
add_custom_command( |
| 85 |
OUTPUT |
| 86 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_generators.c |
| 87 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_generators.h |
| 88 |
COMMAND |
| 89 |
${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/generate.py --emit -i ${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/specs.json -o ${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_generators |
| 90 |
DEPENDS |
| 91 |
${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/generate.py |
| 92 |
${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/specs.json |
| 93 |
) |
| 94 |
|
| 95 |
add_custom_command( |
| 96 |
OUTPUT |
| 97 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_consumers.c |
| 98 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_consumers.h |
| 99 |
COMMAND |
| 100 |
${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/generate.py --consume -i ${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/specs.json -o ${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_consumers |
| 101 |
DEPENDS |
| 102 |
${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/generate.py |
| 103 |
${CMAKE_CURRENT_SOURCE_DIR}/tools/codec-generator/specs.json |
| 104 |
) |
| 105 |
|
| 106 |
add_custom_target( |
| 107 |
generated_c_files |
| 108 |
DEPENDS |
| 109 |
${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h |
| 110 |
${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h |
| 111 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_generators.c |
| 112 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_generators.h |
| 113 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_consumers.c |
| 114 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_consumers.h |
| 115 |
) |
| 116 |
|
| 117 |
file (GLOB_RECURSE source_files "src/*.h" "src/*.c" "src/*.cpp") |
| 118 |
|
| 119 |
foreach (sfile ${source_files}) |
| 120 |
file (RELATIVE_PATH rfile ${CMAKE_CURRENT_SOURCE_DIR} ${sfile}) |
| 121 |
configure_file (${sfile} ${CMAKE_CURRENT_BINARY_DIR}/${rfile} COPYONLY) |
| 122 |
endforeach () |
| 123 |
|
| 124 |
# Select IO impl |
| 125 |
if(PN_WINAPI) |
| 126 |
set (pn_io_impl src/reactor/io/windows/io.c src/reactor/io/windows/iocp.c src/reactor/io/windows/write_pipeline.c) |
| 127 |
set (pn_selector_impl src/reactor/io/windows/selector.c) |
| 128 |
else(PN_WINAPI) |
| 129 |
set (pn_io_impl src/reactor/io/posix/io.c) |
| 130 |
set (pn_selector_impl src/reactor/io/posix/selector.c) |
| 131 |
endif(PN_WINAPI) |
| 132 |
|
| 133 |
# Link in SASL if present |
| 134 |
if (SASL_IMPL STREQUAL cyrus) |
| 135 |
set(pn_sasl_impl src/sasl/sasl.c src/sasl/default_sasl.c src/sasl/cyrus_sasl.c) |
| 136 |
set(SASL_LIB CyrusSASL::CyrusSASL Threads::Threads) |
| 137 |
elseif (SASL_IMPL STREQUAL none) |
| 138 |
set(pn_sasl_impl src/sasl/sasl.c src/sasl/default_sasl.c src/sasl/cyrus_stub.c) |
| 139 |
endif () |
| 140 |
|
| 141 |
# Set Compiler extra flags for Solaris when using SunStudio |
| 142 |
if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro" ) |
| 143 |
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mt" ) |
| 144 |
endif() |
| 145 |
|
| 146 |
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro" ) |
| 147 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mt") |
| 148 |
endif() |
| 149 |
|
| 150 |
# Link in openssl if present |
| 151 |
if (SSL_IMPL STREQUAL openssl) |
| 152 |
set (pn_ssl_impl src/ssl/openssl.c) |
| 153 |
set (SSL_LIB OpenSSL::SSL Threads::Threads) |
| 154 |
elseif (SSL_IMPL STREQUAL schannel) |
| 155 |
set (pn_ssl_impl src/ssl/schannel.cpp) |
| 156 |
set (SSL_LIB Crypt32.lib Secur32.lib) |
| 157 |
else () |
| 158 |
set (pn_ssl_impl src/ssl/ssl_stub.c) |
| 159 |
endif () |
| 160 |
|
| 161 |
# First check whether we get clock_gettime without any special library linked |
| 162 |
CHECK_SYMBOL_EXISTS(clock_gettime "time.h" CLOCK_GETTIME_IN_LIBC) |
| 163 |
if (CLOCK_GETTIME_IN_LIBC) |
| 164 |
list(APPEND PLATFORM_DEFINITIONS "USE_CLOCK_GETTIME") |
| 165 |
else (CLOCK_GETTIME_IN_LIBC) |
| 166 |
CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_RT) |
| 167 |
if (CLOCK_GETTIME_IN_RT) |
| 168 |
set (TIME_LIB rt) |
| 169 |
list(APPEND PLATFORM_DEFINITIONS "USE_CLOCK_GETTIME") |
| 170 |
else (CLOCK_GETTIME_IN_RT) |
| 171 |
CHECK_SYMBOL_EXISTS(GetSystemTimeAsFileTime "windows.h" WINDOWS_FILETIME) |
| 172 |
if (WINDOWS_FILETIME) |
| 173 |
list(APPEND PLATFORM_DEFINITIONS "USE_WIN_FILETIME") |
| 174 |
else (WINDOWS_FILETIME) |
| 175 |
list(APPEND PLATFORM_DEFINITIONS "USE_GETTIMEOFDAY") |
| 176 |
endif (WINDOWS_FILETIME) |
| 177 |
endif (CLOCK_GETTIME_IN_RT) |
| 178 |
endif (CLOCK_GETTIME_IN_LIBC) |
| 179 |
|
| 180 |
if (PN_WINAPI) |
| 181 |
CHECK_SYMBOL_EXISTS(strerror_s "string.h" STRERROR_S_IN_WINAPI) |
| 182 |
if (STRERROR_S_IN_WINAPI) |
| 183 |
list(APPEND PLATFORM_DEFINITIONS "USE_STRERROR_S") |
| 184 |
else (STRERROR_S_IN_WINAPI) |
| 185 |
if (MINGW) |
| 186 |
message (STATUS, "NOTE: your MinGW version lacks a thread safe strerror") |
| 187 |
list(APPEND PLATFORM_DEFINITIONS "USE_OLD_STRERROR") |
| 188 |
endif (MINGW) |
| 189 |
endif (STRERROR_S_IN_WINAPI) |
| 190 |
else (PN_WINAPI) |
| 191 |
CHECK_SYMBOL_EXISTS(strerror_r "string.h" STRERROR_R_IN_LIBC) |
| 192 |
if (STRERROR_R_IN_LIBC) |
| 193 |
list(APPEND PLATFORM_DEFINITIONS "USE_STRERROR_R") |
| 194 |
endif (STRERROR_R_IN_LIBC) |
| 195 |
endif (PN_WINAPI) |
| 196 |
|
| 197 |
if (PN_WINAPI) |
| 198 |
set (PLATFORM_LIBS ws2_32 Rpcrt4) |
| 199 |
list(APPEND PLATFORM_DEFINITIONS "PN_WINAPI") |
| 200 |
endif (PN_WINAPI) |
| 201 |
|
| 202 |
# Flags for example self-test build |
| 203 |
set(C_EXAMPLE_FLAGS "${C_STANDARD_FLAGS} ${COMPILE_WARNING_FLAGS}") |
| 204 |
set(C_EXAMPLE_LINK_FLAGS "${SANITIZE_FLAGS}") |
| 205 |
|
| 206 |
set(qpid-proton-platform_GNU src/compiler/gcc/start.c) |
| 207 |
set(qpid-proton-platform_Clang src/compiler/gcc/start.c) |
| 208 |
set(qpid-proton-platform_MSVC src/compiler/msvc/start.c) |
| 209 |
|
| 210 |
set(qpid-proton-platform ${qpid-proton-platform_${CMAKE_C_COMPILER_ID}}) |
| 211 |
|
| 212 |
# for full source distribution: |
| 213 |
set (qpid-proton-platform-all |
| 214 |
src/platform/platform.c |
| 215 |
src/reactor/io/windows/io.c |
| 216 |
src/reactor/io/windows/iocp.c |
| 217 |
src/reactor/io/windows/write_pipeline.c |
| 218 |
src/reactor/io/windows/selector.c |
| 219 |
src/reactor/io/posix/io.c |
| 220 |
src/reactor/io/posix/selector.c |
| 221 |
) |
| 222 |
|
| 223 |
# platform specific library build: |
| 224 |
set (qpid-proton-platform-io |
| 225 |
src/platform/platform.c |
| 226 |
${pn_io_impl} |
| 227 |
${pn_selector_impl} |
| 228 |
) |
| 229 |
|
| 230 |
# for full source distribution: |
| 231 |
set (qpid-proton-layers-all |
| 232 |
src/sasl/sasl.c |
| 233 |
src/sasl/default_sasl.c |
| 234 |
src/sasl/cyrus_sasl.c |
| 235 |
src/sasl/cyrus_stub.c |
| 236 |
src/ssl/openssl.c |
| 237 |
src/ssl/schannel.cpp |
| 238 |
src/ssl/ssl_stub.c |
| 239 |
) |
| 240 |
|
| 241 |
# for current build system's environment: |
| 242 |
set (qpid-proton-layers |
| 243 |
${pn_sasl_impl} |
| 244 |
${pn_ssl_impl} |
| 245 |
) |
| 246 |
|
| 247 |
set (qpid-proton-core |
| 248 |
src/core/object/object.c |
| 249 |
src/core/object/list.c |
| 250 |
src/core/object/map.c |
| 251 |
src/core/object/string.c |
| 252 |
src/core/object/iterator.c |
| 253 |
src/core/object/record.c |
| 254 |
|
| 255 |
src/core/init.c |
| 256 |
src/core/memory.c |
| 257 |
src/core/logger.c |
| 258 |
src/core/util.c |
| 259 |
src/core/error.c |
| 260 |
src/core/buffer.c |
| 261 |
src/core/types.c |
| 262 |
|
| 263 |
src/core/framing.c |
| 264 |
src/core/value_dump.c |
| 265 |
|
| 266 |
src/core/codec.c |
| 267 |
src/core/decoder.c |
| 268 |
src/core/encoder.c |
| 269 |
|
| 270 |
src/core/dispatcher.c |
| 271 |
src/core/connection_driver.c |
| 272 |
src/core/engine.c |
| 273 |
src/core/event.c |
| 274 |
src/core/autodetect.c |
| 275 |
src/core/transport.c |
| 276 |
src/core/message.c |
| 277 |
|
| 278 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_generators.c |
| 279 |
${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_consumers.c |
| 280 |
) |
| 281 |
|
| 282 |
set (qpid-proton-include-generated |
| 283 |
${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h |
| 284 |
${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h |
| 285 |
${CMAKE_CURRENT_BINARY_DIR}/include/proton/version.h |
| 286 |
) |
| 287 |
|
| 288 |
set (qpid-proton-extra |
| 289 |
src/core/log.c |
| 290 |
|
| 291 |
src/extra/url.c |
| 292 |
|
| 293 |
src/reactor/reactor.c |
| 294 |
src/reactor/handler.c |
| 295 |
src/reactor/connection.c |
| 296 |
src/reactor/acceptor.c |
| 297 |
src/reactor/selectable.c |
| 298 |
src/reactor/timer.c |
| 299 |
|
| 300 |
src/handlers/handshaker.c |
| 301 |
src/handlers/iohandler.c |
| 302 |
src/handlers/flowcontroller.c |
| 303 |
|
| 304 |
src/messenger/messenger.c |
| 305 |
src/messenger/subscription.c |
| 306 |
src/messenger/store.c |
| 307 |
src/messenger/transform.c |
| 308 |
) |
| 309 |
|
| 310 |
set (qpid-proton-include |
| 311 |
include/proton/cid.h |
| 312 |
include/proton/codec.h |
| 313 |
include/proton/condition.h |
| 314 |
include/proton/connection.h |
| 315 |
include/proton/connection_driver.h |
| 316 |
include/proton/delivery.h |
| 317 |
include/proton/disposition.h |
| 318 |
include/proton/engine.h |
| 319 |
include/proton/error.h |
| 320 |
include/proton/event.h |
| 321 |
include/proton/import_export.h |
| 322 |
include/proton/link.h |
| 323 |
include/proton/listener.h |
| 324 |
include/proton/logger.h |
| 325 |
include/proton/message.h |
| 326 |
include/proton/netaddr.h |
| 327 |
include/proton/object.h |
| 328 |
include/proton/proactor.h |
| 329 |
include/proton/raw_connection.h |
| 330 |
include/proton/sasl.h |
| 331 |
include/proton/sasl_plugin.h |
| 332 |
include/proton/session.h |
| 333 |
include/proton/ssl.h |
| 334 |
include/proton/terminus.h |
| 335 |
include/proton/transport.h |
| 336 |
include/proton/type_compat.h |
| 337 |
include/proton/types.h |
| 338 |
) |
| 339 |
|
| 340 |
set (qpid-proton-include-extra |
| 341 |
include/proton/handlers.h |
| 342 |
include/proton/log.h |
| 343 |
include/proton/messenger.h |
| 344 |
include/proton/reactor.h |
| 345 |
include/proton/selectable.h |
| 346 |
include/proton/url.h |
| 347 |
) |
| 348 |
|
| 349 |
# |
| 350 |
# Choose a proactor: user can set PROACTOR, or if not set pick a default. |
| 351 |
# The default is the first one that passes its build test, in order listed below. |
| 352 |
# "none" disables the proactor even if a default is available. |
| 353 |
# |
| 354 |
set(PROACTOR "" CACHE STRING "Override default proactor, one of: epoll, libuv, iocp, none") |
| 355 |
string(TOLOWER "${PROACTOR}" PROACTOR) |
| 356 |
|
| 357 |
set (qpid-proton-proactor-common |
| 358 |
src/proactor/proactor-internal.c |
| 359 |
src/proactor/netaddr-internal.c |
| 360 |
src/proactor/raw_connection.c |
| 361 |
) |
| 362 |
|
| 363 |
if (PROACTOR STREQUAL "epoll" OR (NOT PROACTOR AND NOT BUILD_PROACTOR)) |
| 364 |
check_symbol_exists(epoll_wait "sys/epoll.h" HAVE_EPOLL) |
| 365 |
if (HAVE_EPOLL) |
| 366 |
set (PROACTOR_OK epoll) |
| 367 |
set (qpid-proton-proactor src/proactor/epoll.c src/proactor/epoll_raw_connection.c src/proactor/epoll_timer.c ${qpid-proton-proactor-common}) |
| 368 |
set (PROACTOR_LIBS Threads::Threads ${TIME_LIB}) |
| 369 |
endif() |
| 370 |
endif() |
| 371 |
|
| 372 |
if (PROACTOR STREQUAL "iocp" OR (NOT PROACTOR AND NOT PROACTOR_OK)) |
| 373 |
if(WIN32 AND NOT CYGWIN) |
| 374 |
set (PROACTOR_OK iocp) |
| 375 |
set (qpid-proton-proactor src/proactor/win_iocp.cpp ${qpid-proton-proactor-common}) |
| 376 |
endif(WIN32 AND NOT CYGWIN) |
| 377 |
endif() |
| 378 |
|
| 379 |
if (PROACTOR STREQUAL "libuv" OR (NOT PROACTOR AND NOT PROACTOR_OK)) |
| 380 |
find_package(Libuv) |
| 381 |
if (Libuv_FOUND) |
| 382 |
set (PROACTOR_OK libuv) |
| 383 |
set (qpid-proton-proactor src/proactor/libuv.c ${qpid-proton-proactor-common}) |
| 384 |
set (PROACTOR_LIBS Libuv::Libuv) |
| 385 |
endif() |
| 386 |
endif() |
| 387 |
|
| 388 |
if (PROACTOR_OK) |
| 389 |
message(STATUS "Building the ${PROACTOR_OK} proactor") |
| 390 |
elseif (PROACTOR AND NOT PROACTOR STREQUAL "none") |
| 391 |
message(FATAL_ERROR "Cannot build the ${PROACTOR} proactor") |
| 392 |
endif() |
| 393 |
|
| 394 |
if (BUILD_TLS) |
| 395 |
if((PROACTOR_OK STREQUAL epoll) AND (SSL_IMPL STREQUAL openssl)) |
| 396 |
set (qpid-proton-tls src/tls/openssl.c) |
| 397 |
message(STATUS "Building the raw connection TLS library") |
| 398 |
else () |
| 399 |
message(FATAL_ERROR "Cannot currently build the raw connection TLS library without the epoll proactor and OpenSSL") |
| 400 |
endif () |
| 401 |
endif (BUILD_TLS) |
| 402 |
|
| 403 |
source_group("API Header Files" FILES ${qpid-proton-include} ${qpid-proton-include-extra}) |
| 404 |
|
| 405 |
set_source_files_properties ( |
| 406 |
${qpid-proton-core} |
| 407 |
${qpid-proton-layers} |
| 408 |
${qpid-proton-extra} |
| 409 |
${qpid-proton-platform} |
| 410 |
PROPERTIES |
| 411 |
COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${C_STANDARD_FLAGS}" |
| 412 |
) |
| 413 |
|
| 414 |
set_source_files_properties ( |
| 415 |
${qpid-proton-platform-io} |
| 416 |
PROPERTIES |
| 417 |
COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${C_EXTENDED_FLAGS}" |
| 418 |
COMPILE_DEFINITIONS "${PLATFORM_DEFINITIONS}" |
| 419 |
) |
| 420 |
|
| 421 |
set(qpid-proton-core-src |
| 422 |
${qpid-proton-core} |
| 423 |
${qpid-proton-layers} |
| 424 |
${qpid-proton-platform} |
| 425 |
${qpid-proton-include} |
| 426 |
${qpid-proton-include-generated} |
| 427 |
) |
| 428 |
|
| 429 |
add_library (qpid-proton-core-objects OBJECT ${qpid-proton-core-src}) |
| 430 |
add_dependencies (qpid-proton-core-objects generated_c_files) |
| 431 |
set_target_properties(qpid-proton-core-objects PROPERTIES |
| 432 |
POSITION_INDEPENDENT_CODE ON |
| 433 |
COMPILE_FLAGS "${LTO}" |
| 434 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}") |
| 435 |
target_compile_definitions(qpid-proton-core-objects PRIVATE qpid_proton_core_EXPORTS) |
| 436 |
|
| 437 |
# Can't use target_link_libraries() because cmake 2.8.12 doesn't allow object libraries as the first param |
| 438 |
# otherwise for cmake 3.9 and on this would be: |
| 439 |
# target_link_libraries (qpid-proton-core-objects ${SSL_LIB} ${SASL_LIB} ${PLATFORM_LIBS}) |
| 440 |
target_compile_definitions(qpid-proton-core-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-core,COMPILE_DEFINITIONS>) |
| 441 |
target_compile_options (qpid-proton-core-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-core,COMPILE_OPTIONS>) |
| 442 |
target_include_directories(qpid-proton-core-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-core,INCLUDE_DIRECTORIES>) |
| 443 |
|
| 444 |
add_library (qpid-proton-platform-io-objects OBJECT ${qpid-proton-platform-io}) |
| 445 |
set_target_properties(qpid-proton-platform-io-objects PROPERTIES |
| 446 |
POSITION_INDEPENDENT_CODE ON |
| 447 |
C_EXTENSIONS ON |
| 448 |
COMPILE_FLAGS "${LTO}" |
| 449 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}") |
| 450 |
target_compile_definitions(qpid-proton-platform-io-objects PRIVATE qpid_proton_EXPORTS) |
| 451 |
|
| 452 |
target_compile_definitions(qpid-proton-platform-io-objects PRIVATE $<TARGET_PROPERTY:qpid-proton,COMPILE_DEFINITIONS>) |
| 453 |
target_compile_options (qpid-proton-platform-io-objects PRIVATE $<TARGET_PROPERTY:qpid-proton,COMPILE_OPTIONS>) |
| 454 |
target_include_directories(qpid-proton-platform-io-objects PRIVATE $<TARGET_PROPERTY:qpid-proton,INCLUDE_DIRECTORIES>) |
| 455 |
|
| 456 |
add_library (qpid-proton-core SHARED $<TARGET_OBJECTS:qpid-proton-core-objects>) |
| 457 |
target_link_libraries (qpid-proton-core LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${PLATFORM_LIBS}) |
| 458 |
set_target_properties (qpid-proton-core |
| 459 |
PROPERTIES |
| 460 |
VERSION "${PN_LIB_CORE_VERSION}" |
| 461 |
SOVERSION "${PN_LIB_CORE_MAJOR_VERSION}" |
| 462 |
COMPILE_FLAGS "${LTO}" |
| 463 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}" |
| 464 |
EXPORT_NAME core) |
| 465 |
|
| 466 |
if (BUILD_STATIC_LIBS) |
| 467 |
add_library (qpid-proton-core-static STATIC ${qpid-proton-core-src}) |
| 468 |
target_compile_definitions(qpid-proton-core-static PUBLIC PROTON_DECLARE_STATIC) |
| 469 |
target_link_libraries (qpid-proton-core-static ${SSL_LIB} ${SASL_LIB} ${PLATFORM_LIBS}) |
| 470 |
set_target_properties(qpid-proton-core-static PROPERTIES |
| 471 |
EXPORT_NAME core) |
| 472 |
endif(BUILD_STATIC_LIBS) |
| 473 |
|
| 474 |
if (qpid-proton-proactor) |
| 475 |
set(HAS_PROACTOR True) |
| 476 |
set_source_files_properties (${qpid-proton-proactor} PROPERTIES |
| 477 |
COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${C_STANDARD_FLAGS}" |
| 478 |
) |
| 479 |
|
| 480 |
add_library (qpid-proton-proactor-objects OBJECT ${qpid-proton-proactor}) |
| 481 |
set_target_properties(qpid-proton-proactor-objects PROPERTIES |
| 482 |
POSITION_INDEPENDENT_CODE ON |
| 483 |
COMPILE_FLAGS "${LTO}" |
| 484 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}") |
| 485 |
target_compile_definitions(qpid-proton-proactor-objects PRIVATE qpid_proton_proactor_EXPORTS) |
| 486 |
set(TARGET_OBJECTS_qpid-proton-proactor-objects "$<TARGET_OBJECTS:qpid-proton-proactor-objects>") |
| 487 |
|
| 488 |
# Can't use target_link_libraries() because cmake 2.8.12 doesn't allow object libraries as the first param |
| 489 |
# otherwise for cmake 3.9 and on this would be: |
| 490 |
# target_link_libraries (qpid-proton-proactor-objects ${PLATFORM_LIBS} ${PROACTOR_LIBS}) |
| 491 |
target_compile_definitions(qpid-proton-proactor-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-proactor,COMPILE_DEFINITIONS>) |
| 492 |
target_compile_options (qpid-proton-proactor-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-proactor,COMPILE_OPTIONS>) |
| 493 |
target_include_directories(qpid-proton-proactor-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-proactor,INCLUDE_DIRECTORIES>) |
| 494 |
|
| 495 |
add_library (qpid-proton-proactor SHARED $<TARGET_OBJECTS:qpid-proton-proactor-objects>) |
| 496 |
target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) |
| 497 |
target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) |
| 498 |
set_target_properties (qpid-proton-proactor |
| 499 |
PROPERTIES |
| 500 |
VERSION "${PN_LIB_PROACTOR_VERSION}" |
| 501 |
SOVERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}" |
| 502 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}" |
| 503 |
COMPILE_FLAGS "${LTO}" |
| 504 |
EXPORT_NAME proactor |
| 505 |
) |
| 506 |
if (BUILD_STATIC_LIBS) |
| 507 |
add_library (qpid-proton-proactor-static STATIC ${qpid-proton-proactor}) |
| 508 |
target_compile_definitions(qpid-proton-proactor-static PUBLIC PROTON_DECLARE_STATIC) |
| 509 |
target_link_libraries (qpid-proton-proactor-static LINK_PUBLIC qpid-proton-core-static) |
| 510 |
target_link_libraries (qpid-proton-proactor-static PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) |
| 511 |
set_target_properties(qpid-proton-proactor-static PROPERTIES |
| 512 |
EXPORT_NAME proactor) |
| 513 |
set(TARGET_qpid-proton-proactor-static qpid-proton-proactor-static) |
| 514 |
endif(BUILD_STATIC_LIBS) |
| 515 |
endif() |
| 516 |
|
| 517 |
set(qpid-proton-noncore-src |
| 518 |
# Proton Reactor/Messenger |
| 519 |
${qpid-proton-extra} |
| 520 |
${qpid-proton-include-extra} |
| 521 |
) |
| 522 |
|
| 523 |
add_library (qpid-proton SHARED |
| 524 |
$<TARGET_OBJECTS:qpid-proton-core-objects> |
| 525 |
$<TARGET_OBJECTS:qpid-proton-platform-io-objects> |
| 526 |
${TARGET_OBJECTS_qpid-proton-proactor-objects} |
| 527 |
${qpid-proton-noncore-src}) |
| 528 |
target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) |
| 529 |
set_target_properties (qpid-proton |
| 530 |
PROPERTIES |
| 531 |
VERSION "${PN_LIB_LEGACY_VERSION}" |
| 532 |
SOVERSION "${PN_LIB_LEGACY_MAJOR_VERSION}" |
| 533 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}" |
| 534 |
COMPILE_FLAGS "${LTO}" |
| 535 |
EXPORT_NAME qpid-proton |
| 536 |
) |
| 537 |
|
| 538 |
if (BUILD_STATIC_LIBS) |
| 539 |
add_library (qpid-proton-platform-io-static OBJECT ${qpid-proton-platform-io}) |
| 540 |
set_target_properties(qpid-proton-platform-io-static PROPERTIES |
| 541 |
C_EXTENSIONS ON) |
| 542 |
add_library(qpid-proton-static STATIC $<TARGET_OBJECTS:qpid-proton-platform-io-static> ${qpid-proton-noncore-src}) |
| 543 |
target_compile_definitions(qpid-proton-static PUBLIC PROTON_DECLARE_STATIC) |
| 544 |
target_link_libraries (qpid-proton-static |
| 545 |
qpid-proton-core-static |
| 546 |
${TARGET_qpid-proton-proactor-static} |
| 547 |
${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) |
| 548 |
set_target_properties(qpid-proton-static PROPERTIES |
| 549 |
EXPORT_NAME qpid-proton) |
| 550 |
endif(BUILD_STATIC_LIBS) |
| 551 |
|
| 552 |
if (qpid-proton-tls) |
| 553 |
set(HAS_TLS True) |
| 554 |
set_source_files_properties (${qpid-proton-tls} PROPERTIES |
| 555 |
COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${C_STANDARD_FLAGS}" |
| 556 |
) |
| 557 |
|
| 558 |
add_library (qpid-proton-tls-objects OBJECT ${qpid-proton-tls}) |
| 559 |
target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) |
| 560 |
target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) |
| 561 |
set_target_properties(qpid-proton-tls-objects PROPERTIES |
| 562 |
POSITION_INDEPENDENT_CODE ON |
| 563 |
COMPILE_FLAGS "${LTO}" |
| 564 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}") |
| 565 |
target_compile_definitions(qpid-proton-tls-objects PRIVATE qpid_proton_tls_EXPORTS) |
| 566 |
set(TARGET_OBJECTS_qpid-proton-tls-objects "$<TARGET_OBJECTS:qpid-proton-tls-objects>") |
| 567 |
|
| 568 |
# Can't use target_link_libraries() because cmake 2.8.12 doesn't allow object libraries as the first param |
| 569 |
# otherwise for cmake 3.9 and on this would be: |
| 570 |
# target_link_libraries (qpid-proton-tls-objects ${SSL_LIB} ${PLATFORM_LIBS}) |
| 571 |
target_compile_definitions(qpid-proton-tls-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-tls,COMPILE_DEFINITIONS>) |
| 572 |
target_compile_options (qpid-proton-tls-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-tls,COMPILE_OPTIONS>) |
| 573 |
target_include_directories(qpid-proton-tls-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-tls,INCLUDE_DIRECTORIES>) |
| 574 |
|
| 575 |
add_library (qpid-proton-tls SHARED $<TARGET_OBJECTS:qpid-proton-tls-objects>) |
| 576 |
target_link_libraries (qpid-proton-tls LINK_PUBLIC qpid-proton-core) |
| 577 |
target_link_libraries (qpid-proton-tls LINK_PRIVATE ${SSL_LIB} ${PLATFORM_LIBS}) |
| 578 |
set_target_properties (qpid-proton-tls |
| 579 |
PROPERTIES |
| 580 |
VERSION "${PN_LIB_TLS_VERSION}" |
| 581 |
SOVERSION "${PN_LIB_TLS_MAJOR_VERSION}" |
| 582 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}" |
| 583 |
COMPILE_FLAGS "${LTO}" |
| 584 |
EXPORT_NAME tls |
| 585 |
) |
| 586 |
if (BUILD_STATIC_LIBS) |
| 587 |
add_library (qpid-proton-tls-static STATIC ${qpid-proton-tls}) |
| 588 |
target_compile_definitions(qpid-proton-tls-static PUBLIC PROTON_DECLARE_STATIC) |
| 589 |
target_link_libraries (qpid-proton-tls-static PRIVATE ${PLATFORM_LIBS}) |
| 590 |
set_target_properties(qpid-proton-tls-static PROPERTIES |
| 591 |
EXPORT_NAME tls) |
| 592 |
set(TARGET_qpid-proton-tls-static qpid-proton-tls-static) |
| 593 |
endif(BUILD_STATIC_LIBS) |
| 594 |
endif () |
| 595 |
|
| 596 |
|
| 597 |
# Install executables and libraries |
| 598 |
install(TARGETS qpid-proton qpid-proton-core |
| 599 |
EXPORT ProtonTargets |
| 600 |
RUNTIME DESTINATION bin |
| 601 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 602 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 603 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 604 |
if (BUILD_STATIC_LIBS) |
| 605 |
install(TARGETS qpid-proton-static qpid-proton-core-static |
| 606 |
EXPORT ProtonTargetsStatic |
| 607 |
RUNTIME DESTINATION bin |
| 608 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 609 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 610 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 611 |
endif() |
| 612 |
|
| 613 |
# Install windows pdb files |
| 614 |
if (MSVC) |
| 615 |
install(FILES |
| 616 |
$<TARGET_PDB_FILE:qpid-proton> |
| 617 |
$<TARGET_PDB_FILE:qpid-proton-core> |
| 618 |
DESTINATION bin |
| 619 |
CONFIGURATIONS RelWithDebInfo Debug |
| 620 |
OPTIONAL) |
| 621 |
endif (MSVC) |
| 622 |
|
| 623 |
if (HAS_PROACTOR) |
| 624 |
install(TARGETS qpid-proton-proactor ${STATIC_LIBS} |
| 625 |
EXPORT ProtonTargets |
| 626 |
RUNTIME DESTINATION bin |
| 627 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 628 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 629 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 630 |
if (BUILD_STATIC_LIBS) |
| 631 |
install(TARGETS qpid-proton-proactor-static |
| 632 |
EXPORT ProtonTargetsStatic |
| 633 |
RUNTIME DESTINATION bin |
| 634 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 635 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 636 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 637 |
endif() |
| 638 |
|
| 639 |
# Install windows pdb files |
| 640 |
if (MSVC) |
| 641 |
install(FILES $<TARGET_PDB_FILE:qpid-proton-proactor> |
| 642 |
DESTINATION bin |
| 643 |
CONFIGURATIONS RelWithDebInfo Debug |
| 644 |
OPTIONAL) |
| 645 |
endif (MSVC) |
| 646 |
endif () |
| 647 |
|
| 648 |
if (HAS_TLS) |
| 649 |
install(TARGETS qpid-proton-tls ${STATIC_LIBS} |
| 650 |
EXPORT ProtonTargets |
| 651 |
RUNTIME DESTINATION bin |
| 652 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 653 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 654 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 655 |
if (BUILD_STATIC_LIBS) |
| 656 |
install(TARGETS qpid-proton-tls-static |
| 657 |
EXPORT ProtonTargetsStatic |
| 658 |
RUNTIME DESTINATION bin |
| 659 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 660 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 661 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 662 |
endif() |
| 663 |
|
| 664 |
# Install windows pdb files |
| 665 |
if (MSVC) |
| 666 |
install(FILES $<TARGET_PDB_FILE:qpid-proton-tls> |
| 667 |
DESTINATION bin |
| 668 |
CONFIGURATIONS RelWithDebInfo Debug |
| 669 |
OPTIONAL) |
| 670 |
endif (MSVC) |
| 671 |
endif () |
| 672 |
|
| 673 |
# Install header files |
| 674 |
file(GLOB headers "${CMAKE_CURRENT_BINARY_DIR}/include/proton/*.[hi]") |
| 675 |
install (FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/proton) |
| 676 |
|
| 677 |
# Set ${VAR}/${VAR}DEBUG variables, configure and install the packageconf files for LIB |
| 678 |
macro(configure_lib VAR LIB) |
| 679 |
if(DEFINED CMAKE_IMPORT_LIBRARY_PREFIX) |
| 680 |
set(LIB_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX}) |
| 681 |
set(LIB_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX}) |
| 682 |
else() |
| 683 |
set(LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) |
| 684 |
set(LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) |
| 685 |
endif() |
| 686 |
set(${VAR} ${LIB_PREFIX}${LIB}${LIB_SUFFIX}) |
| 687 |
set("${VAR}DEBUG" ${LIB_PREFIX}${LIB}${CMAKE_DEBUG_POSTFIX}${LIB_SUFFIX}) |
| 688 |
configure_file( |
| 689 |
${CMAKE_CURRENT_SOURCE_DIR}/src/lib${LIB}.pc.in |
| 690 |
${CMAKE_CURRENT_BINARY_DIR}/lib${LIB}.pc @ONLY) |
| 691 |
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${LIB}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) |
| 692 |
endmacro() |
| 693 |
|
| 694 |
configure_lib(PROTONLIB qpid-proton) |
| 695 |
configure_lib(PROTONCORELIB qpid-proton-core) |
| 696 |
if(HAS_PROACTOR) |
| 697 |
configure_lib(PROTONPROACTORLIB qpid-proton-proactor) |
| 698 |
endif(HAS_PROACTOR) |
| 699 |
if(HAS_TLS) |
| 700 |
configure_lib(PROTONTLSLIB qpid-proton-tls) |
| 701 |
endif(HAS_TLS) |
| 702 |
|
| 703 |
install(EXPORT ProtonTargets |
| 704 |
FILE ProtonTargets.cmake |
| 705 |
NAMESPACE Proton:: |
| 706 |
DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) |
| 707 |
if (BUILD_STATIC_LIBS) |
| 708 |
install(EXPORT ProtonTargetsStatic |
| 709 |
FILE ProtonTargetsStatic.cmake |
| 710 |
NAMESPACE Proton:: |
| 711 |
DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) |
| 712 |
endif() |
| 713 |
|
| 714 |
include(CMakePackageConfigHelpers) |
| 715 |
include(WriteBasicConfigVersionFile) |
| 716 |
|
| 717 |
configure_package_config_file( |
| 718 |
${CMAKE_CURRENT_SOURCE_DIR}/src/ProtonConfig.cmake.in |
| 719 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonConfig.cmake |
| 720 |
PATH_VARS INCLUDE_INSTALL_DIR |
| 721 |
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) |
| 722 |
write_basic_config_version_file( |
| 723 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonConfigVersion.cmake |
| 724 |
VERSION ${PN_VERSION} |
| 725 |
COMPATIBILITY AnyNewerVersion) |
| 726 |
install (FILES |
| 727 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonConfig.cmake |
| 728 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonConfigVersion.cmake |
| 729 |
DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) |
| 730 |
install (FILES |
| 731 |
../tools/cmake/Modules/FindCyrusSASL.cmake |
| 732 |
../tools/cmake/Modules/FindOpenSSL.cmake |
| 733 |
../tools/cmake/Modules/FindThreads.cmake |
| 734 |
DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) |
| 735 |
|
| 736 |
if (ENABLE_BENCHMARKS) |
| 737 |
add_subdirectory(benchmarks) |
| 738 |
endif (ENABLE_BENCHMARKS) |
| 739 |
|
| 740 |
add_subdirectory(docs) |
| 741 |
if (BUILD_EXAMPLES) |
| 742 |
add_subdirectory(examples) |
| 743 |
endif (BUILD_EXAMPLES) |
| 744 |
if (BUILD_TESTING) |
| 745 |
add_subdirectory(tests) |
| 746 |
endif (BUILD_TESTING) |
| 747 |
add_subdirectory(tools) |
| 748 |
|
| 749 |
install (DIRECTORY examples/ |
| 750 |
DESTINATION "${PROTON_SHARE}/examples/c" |
| 751 |
USE_SOURCE_PERMISSIONS |
| 752 |
PATTERN "ProtonConfig.cmake" EXCLUDE |
| 753 |
PATTERN "testme" EXCLUDE) |