| 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(CMakeDependentOption) |
| 21 |
enable_language(CXX) |
| 22 |
|
| 23 |
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) |
| 24 |
find_package(Threads) |
| 25 |
|
| 26 |
include(versions.cmake) |
| 27 |
|
| 28 |
# Check for JSON-CPP support for connection configuration |
| 29 |
find_package(JsonCpp) |
| 30 |
option(ENABLE_JSONCPP "Use jsoncpp parser for connection configuration" ${JsonCpp_FOUND}) |
| 31 |
if (ENABLE_JSONCPP) |
| 32 |
include_directories(${JsonCpp_INCLUDE_DIRS}) |
| 33 |
set(CONNECT_CONFIG_SRC src/connect_config.cpp) |
| 34 |
set(CONNECT_CONFIG_LIBS ${JsonCpp_LIBRARY}) |
| 35 |
else() |
| 36 |
set(CONNECT_CONFIG_SRC src/connect_config_dummy.cpp) |
| 37 |
endif() |
| 38 |
|
| 39 |
list(APPEND PLATFORM_LIBS Threads::Threads) |
| 40 |
|
| 41 |
set(CXX_EXAMPLE_FLAGS "${CXX_WARNING_FLAGS} ${CXX_STANDARD}") |
| 42 |
set(CXX_EXAMPLE_LINK_FLAGS "${SANITIZE_FLAGS}") |
| 43 |
|
| 44 |
include_directories ( |
| 45 |
"${CMAKE_SOURCE_DIR}/c/include" |
| 46 |
"${CMAKE_SOURCE_DIR}/c/src" # Here because of a naughty looking dependency on message-internal.h |
| 47 |
"${CMAKE_CURRENT_SOURCE_DIR}/include" |
| 48 |
"${PN_C_INCLUDE_DIR}" |
| 49 |
"${CMAKE_CURRENT_BINARY_DIR}" |
| 50 |
) |
| 51 |
|
| 52 |
add_definitions(${CXX_STANDARD} ${CXX_WARNING_FLAGS} "-DPN_CPP_USE_DEPRECATED_API=1") |
| 53 |
|
| 54 |
set(qpid-proton-cpp-source |
| 55 |
src/binary.cpp |
| 56 |
src/byte_array.cpp |
| 57 |
src/map.cpp |
| 58 |
src/connection.cpp |
| 59 |
src/connection_driver.cpp |
| 60 |
src/connection_options.cpp |
| 61 |
src/container.cpp |
| 62 |
src/proactor_container_impl.cpp |
| 63 |
src/contexts.cpp |
| 64 |
src/data.cpp |
| 65 |
src/decimal.cpp |
| 66 |
src/decoder.cpp |
| 67 |
src/delivery.cpp |
| 68 |
src/duration.cpp |
| 69 |
src/encoder.cpp |
| 70 |
src/endpoint.cpp |
| 71 |
src/error.cpp |
| 72 |
src/error_condition.cpp |
| 73 |
src/handler.cpp |
| 74 |
src/link.cpp |
| 75 |
src/link_namer.cpp |
| 76 |
src/listener.cpp |
| 77 |
src/message.cpp |
| 78 |
src/messaging_adapter.cpp |
| 79 |
src/node_options.cpp |
| 80 |
src/null.cpp |
| 81 |
src/object.cpp |
| 82 |
src/proton_bits.cpp |
| 83 |
src/receiver.cpp |
| 84 |
src/receiver_options.cpp |
| 85 |
src/reconnect_options.cpp |
| 86 |
src/returned.cpp |
| 87 |
src/sasl.cpp |
| 88 |
src/scalar_base.cpp |
| 89 |
src/sender.cpp |
| 90 |
src/sender_options.cpp |
| 91 |
src/session.cpp |
| 92 |
src/session_options.cpp |
| 93 |
src/source.cpp |
| 94 |
src/ssl.cpp |
| 95 |
src/ssl_options.cpp |
| 96 |
src/target.cpp |
| 97 |
src/terminus.cpp |
| 98 |
src/timestamp.cpp |
| 99 |
src/tracker.cpp |
| 100 |
src/transfer.cpp |
| 101 |
src/transport.cpp |
| 102 |
src/type_id.cpp |
| 103 |
src/url.cpp |
| 104 |
src/uuid.cpp |
| 105 |
src/value.cpp |
| 106 |
src/work_queue.cpp |
| 107 |
${CONNECT_CONFIG_SRC} |
| 108 |
) |
| 109 |
|
| 110 |
add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) |
| 111 |
if(BUILD_STATIC_LIBS) |
| 112 |
add_library(qpid-proton-cpp-static STATIC ${qpid-proton-cpp-source}) |
| 113 |
target_compile_definitions(qpid-proton-cpp-static |
| 114 |
PRIVATE PROTON_DECLARE_STATIC |
| 115 |
PUBLIC PN_CPP_DECLARE_STATIC) |
| 116 |
set_target_properties ( |
| 117 |
qpid-proton-cpp-static |
| 118 |
PROPERTIES |
| 119 |
EXPORT_NAME cpp) |
| 120 |
endif(BUILD_STATIC_LIBS) |
| 121 |
|
| 122 |
target_link_libraries (qpid-proton-cpp LINK_PRIVATE ${PLATFORM_LIBS} qpid-proton-core qpid-proton-proactor ${CONNECT_CONFIG_LIBS}) |
| 123 |
|
| 124 |
set_target_properties ( |
| 125 |
qpid-proton-cpp |
| 126 |
PROPERTIES |
| 127 |
LINKER_LANGUAGE CXX |
| 128 |
VERSION "${PN_LIB_CPP_VERSION}" |
| 129 |
SOVERSION "${PN_LIB_CPP_MAJOR_VERSION}" |
| 130 |
LINK_FLAGS "${CATCH_UNDEFINED} ${LINK_LTO}" |
| 131 |
COMPILE_FLAGS "${LTO}" |
| 132 |
EXPORT_NAME cpp |
| 133 |
) |
| 134 |
|
| 135 |
## Install |
| 136 |
|
| 137 |
install(TARGETS qpid-proton-cpp |
| 138 |
EXPORT ProtonCppTargets |
| 139 |
RUNTIME DESTINATION bin |
| 140 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 141 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 142 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 143 |
if (BUILD_STATIC_LIBS) |
| 144 |
install(TARGETS qpid-proton-cpp-static |
| 145 |
EXPORT ProtonCppStaticTargets |
| 146 |
RUNTIME DESTINATION bin |
| 147 |
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} |
| 148 |
LIBRARY DESTINATION ${LIB_INSTALL_DIR} |
| 149 |
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}) |
| 150 |
endif () |
| 151 |
|
| 152 |
# Install windows qpid-proton-cpp pdb files |
| 153 |
if (MSVC) |
| 154 |
install(FILES $<TARGET_PDB_FILE:qpid-proton-cpp> |
| 155 |
DESTINATION bin |
| 156 |
CONFIGURATIONS RelWithDebInfo Debug |
| 157 |
OPTIONAL) |
| 158 |
endif (MSVC) |
| 159 |
|
| 160 |
install (DIRECTORY "include/proton" DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.hpp") |
| 161 |
install (DIRECTORY "examples/" |
| 162 |
DESTINATION "${PROTON_SHARE}/examples/cpp" |
| 163 |
USE_SOURCE_PERMISSIONS |
| 164 |
PATTERN "ProtonCppConfig.cmake" EXCLUDE |
| 165 |
PATTERN "testme" EXCLUDE) |
| 166 |
|
| 167 |
if (DEFINED CMAKE_IMPORT_LIBRARY_PREFIX) |
| 168 |
set(PROTONCPPLIB ${CMAKE_IMPORT_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_IMPORT_LIBRARY_SUFFIX}) |
| 169 |
set(PROTONCPPLIBDEBUG ${CMAKE_IMPORT_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_DEBUG_POSTFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}) |
| 170 |
else () |
| 171 |
set(PROTONCPPLIB ${CMAKE_SHARED_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_SHARED_LIBRARY_SUFFIX}) |
| 172 |
set(PROTONCPPLIBDEBUG ${CMAKE_SHARED_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}) |
| 173 |
endif () |
| 174 |
|
| 175 |
if (BUILD_EXAMPLES) |
| 176 |
add_subdirectory(examples) |
| 177 |
endif (BUILD_EXAMPLES) |
| 178 |
add_subdirectory(docs) |
| 179 |
|
| 180 |
# Pkg config file |
| 181 |
configure_file( |
| 182 |
${CMAKE_CURRENT_SOURCE_DIR}/libqpid-proton-cpp.pc.in |
| 183 |
${CMAKE_CURRENT_BINARY_DIR}/libqpid-proton-cpp.pc @ONLY) |
| 184 |
install (FILES |
| 185 |
${CMAKE_CURRENT_BINARY_DIR}/libqpid-proton-cpp.pc |
| 186 |
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) |
| 187 |
|
| 188 |
install(EXPORT ProtonCppTargets |
| 189 |
FILE ProtonCppTargets.cmake |
| 190 |
NAMESPACE Proton:: |
| 191 |
DESTINATION ${LIB_INSTALL_DIR}/cmake/ProtonCpp) |
| 192 |
if (BUILD_STATIC_LIBS) |
| 193 |
install(EXPORT ProtonCppStaticTargets |
| 194 |
FILE ProtonCppTargetsStatic.cmake |
| 195 |
NAMESPACE Proton:: |
| 196 |
DESTINATION ${LIB_INSTALL_DIR}/cmake/ProtonCpp) |
| 197 |
endif () |
| 198 |
|
| 199 |
include(CMakePackageConfigHelpers) |
| 200 |
include(WriteBasicConfigVersionFile) |
| 201 |
|
| 202 |
configure_package_config_file( |
| 203 |
${CMAKE_CURRENT_SOURCE_DIR}/ProtonCppConfig.cmake.in |
| 204 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonCppConfig.cmake |
| 205 |
PATH_VARS INCLUDE_INSTALL_DIR |
| 206 |
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/ProtonCpp) |
| 207 |
write_basic_config_version_file( |
| 208 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonCppConfigVersion.cmake |
| 209 |
VERSION ${PN_VERSION} |
| 210 |
COMPATIBILITY AnyNewerVersion) |
| 211 |
install (FILES |
| 212 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonCppConfig.cmake |
| 213 |
${CMAKE_CURRENT_BINARY_DIR}/ProtonCppConfigVersion.cmake |
| 214 |
DESTINATION ${LIB_INSTALL_DIR}/cmake/ProtonCpp) |
| 215 |
|
| 216 |
if (BUILD_TESTING) |
| 217 |
include(tests.cmake) |
| 218 |
endif (BUILD_TESTING) |
| 219 |
|
| 220 |
if (ENABLE_BENCHMARKS) |
| 221 |
add_subdirectory(benchmarks) |
| 222 |
endif (ENABLE_BENCHMARKS) |