| 1 |
#Copyright (c) Microsoft. All rights reserved. |
| 2 |
#Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
cmake_minimum_required(VERSION 3.5) |
| 5 |
project(uamqp) |
| 6 |
|
| 7 |
FILE(READ ${CMAKE_CURRENT_LIST_DIR}/version.txt UAMQP_VERSION) |
| 8 |
|
| 9 |
option(run_e2e_tests "set run_e2e_tests to ON to run e2e tests (default is OFF) [if possible, they are always built]" OFF) |
| 10 |
option(run_unittests "set run_unittests to ON to run unittests (default is OFF)" OFF) |
| 11 |
option(skip_samples "set skip_samples to ON to skip building samples (default is OFF)[if possible, they are always built]" OFF) |
| 12 |
option(use_installed_dependencies "set use_installed_dependencies to ON to use installed packages instead of building dependencies from submodules" OFF) |
| 13 |
option(memory_trace "set memory_trace to ON if memory usage is to be used, set to OFF to not use it" OFF) |
| 14 |
option(use_custom_heap "use externally defined heap functions instead of the malloc family" OFF) |
| 15 |
option(use_latest_windows_sdk "use latest windows sdk if available (default is OFF)" OFF) |
| 16 |
option(latest_windows_sdk_shared_include_path "the path to Windows SDK shared include") |
| 17 |
|
| 18 |
if(${use_latest_windows_sdk}) |
| 19 |
include_directories(${latest_windows_sdk_shared_include_path}) |
| 20 |
endif() |
| 21 |
|
| 22 |
if(${use_custom_heap}) |
| 23 |
add_definitions(-DGB_USE_CUSTOM_HEAP) |
| 24 |
endif() |
| 25 |
|
| 26 |
if(${no_logging}) |
| 27 |
add_definitions(-DNO_LOGGING) |
| 28 |
endif() |
| 29 |
|
| 30 |
#do not add or build any tests of the dependencies |
| 31 |
set(original_run_e2e_tests ${run_e2e_tests}) |
| 32 |
set(original_run_int_tests ${run_int_tests}) |
| 33 |
set(original_run_unittests ${run_unittests}) |
| 34 |
|
| 35 |
set(run_e2e_tests OFF) |
| 36 |
set(run_int_tests OFF) |
| 37 |
set(run_unittests OFF) |
| 38 |
|
| 39 |
if(NOT ${use_installed_dependencies}) |
| 40 |
if ((NOT TARGET azure_macro_utils_c) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/azure-macro-utils-c/CMakeLists.txt)) |
| 41 |
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/deps/azure-macro-utils-c) |
| 42 |
endif() |
| 43 |
if ((NOT TARGET umock_c) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/umock-c/CMakeLists.txt)) |
| 44 |
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/deps/umock-c) |
| 45 |
endif() |
| 46 |
|
| 47 |
if(${original_run_e2e_tests} OR ${original_run_unittests}) |
| 48 |
if ((NOT TARGET testrunnerswitcher) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/azure-c-testrunnerswitcher/CMakeLists.txt)) |
| 49 |
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/deps/azure-c-testrunnerswitcher) |
| 50 |
endif() |
| 51 |
if ((NOT TARGET ctest) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/azure-ctest/CMakeLists.txt)) |
| 52 |
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/deps/azure-ctest) |
| 53 |
endif() |
| 54 |
endif() |
| 55 |
if ((NOT TARGET aziotsharedutil) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/azure-c-shared-utility/CMakeLists.txt)) |
| 56 |
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/deps/azure-c-shared-utility) |
| 57 |
endif() |
| 58 |
else() |
| 59 |
if (NOT azure_macro_utils_cFOUND) |
| 60 |
find_package(azure_macro_utils_c REQUIRED CONFIG) |
| 61 |
endif () |
| 62 |
if (NOT umock_cFOUND) |
| 63 |
find_package(umock_c REQUIRED CONFIG) |
| 64 |
endif () |
| 65 |
if (NOT azure_c_shared_utilityFOUND) |
| 66 |
find_package(azure_c_shared_utility REQUIRED CONFIG) |
| 67 |
endif () |
| 68 |
|
| 69 |
include(${azure_c_shared_utility_DIR}/azure_c_shared_utilityConfig.cmake) |
| 70 |
include(${azure_c_shared_utility_DIR}/azure_c_shared_utilityFunctions.cmake) |
| 71 |
include(${azure_c_shared_utility_DIR}/azure_iot_build_rules.cmake) |
| 72 |
endif() |
| 73 |
|
| 74 |
include_directories(${MACRO_UTILS_INC_FOLDER} ${UMOCK_C_INC_FOLDER}) |
| 75 |
|
| 76 |
# Include the common build rules for C shared utility |
| 77 |
if(NOT ${use_installed_dependencies}) |
| 78 |
include(${SHARED_UTIL_FOLDER}/configs/azure_iot_build_rules.cmake) |
| 79 |
|
| 80 |
set_platform_files(${SHARED_UTIL_FOLDER}) |
| 81 |
endif() |
| 82 |
|
| 83 |
|
| 84 |
set(run_e2e_tests ${original_run_e2e_tests}) |
| 85 |
set(run_int_tests ${original_run_int_tests}) |
| 86 |
set(run_unittests ${original_run_unittests}) |
| 87 |
|
| 88 |
if(${memory_trace}) |
| 89 |
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC) |
| 90 |
endif() |
| 91 |
|
| 92 |
option(use_socketio "set use_socketio to ON if socketio is to be included in the library, set to OFF if a different implementation will be provided" ON) |
| 93 |
if(WIN32) |
| 94 |
option(use_schannel "set use_schannel to ON if schannel is to be used, set to OFF to not use schannel" ON) |
| 95 |
option(use_openssl "set use_openssl to ON if openssl is to be used, set to OFF to not use openssl" OFF) |
| 96 |
option(use_wolfssl "set use_wolfssl to ON if wolfssl is to be used, set to OFF to not use wolfssl" OFF) |
| 97 |
else() |
| 98 |
option(use_schannel "set use_schannel to ON if schannel is to be used, set to OFF to not use schannel" OFF) |
| 99 |
option(use_openssl "set use_openssl to ON if openssl is to be used, set to OFF to not use openssl" ON) |
| 100 |
option(use_wolfssl "set use_wolfssl to ON if wolfssl is to be used, set to OFF to not use wolfssl" OFF) |
| 101 |
endif() |
| 102 |
|
| 103 |
# The native apple tlsio does not support socket_io |
| 104 |
if(MACOSX AND NOT ${use_openssl}) |
| 105 |
set(use_socketio OFF) |
| 106 |
endif() |
| 107 |
|
| 108 |
add_definitions(-DREFCOUNT_ATOMIC_DONTCARE) |
| 109 |
add_definitions(-D__STDC_NO_ATOMICS__=1) |
| 110 |
|
| 111 |
|
| 112 |
include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) |
| 113 |
|
| 114 |
if(WIN32) |
| 115 |
include_directories($ENV{OpenSSLDir}/include) |
| 116 |
endif() |
| 117 |
|
| 118 |
set(uamqp_h_files |
| 119 |
./inc/azure_uamqp_c/amqp_definitions_role.h |
| 120 |
./inc/azure_uamqp_c/amqp_definitions_sender_settle_mode.h |
| 121 |
./inc/azure_uamqp_c/amqp_definitions_receiver_settle_mode.h |
| 122 |
./inc/azure_uamqp_c/amqp_definitions_handle.h |
| 123 |
./inc/azure_uamqp_c/amqp_definitions_seconds.h |
| 124 |
./inc/azure_uamqp_c/amqp_definitions_milliseconds.h |
| 125 |
./inc/azure_uamqp_c/amqp_definitions_delivery_tag.h |
| 126 |
./inc/azure_uamqp_c/amqp_definitions_sequence_no.h |
| 127 |
./inc/azure_uamqp_c/amqp_definitions_delivery_number.h |
| 128 |
./inc/azure_uamqp_c/amqp_definitions_transfer_number.h |
| 129 |
./inc/azure_uamqp_c/amqp_definitions_message_format.h |
| 130 |
./inc/azure_uamqp_c/amqp_definitions_ietf_language_tag.h |
| 131 |
./inc/azure_uamqp_c/amqp_definitions_fields.h |
| 132 |
./inc/azure_uamqp_c/amqp_definitions_error.h |
| 133 |
./inc/azure_uamqp_c/amqp_definitions_amqp_error.h |
| 134 |
./inc/azure_uamqp_c/amqp_definitions_connection_error.h |
| 135 |
./inc/azure_uamqp_c/amqp_definitions_session_error.h |
| 136 |
./inc/azure_uamqp_c/amqp_definitions_link_error.h |
| 137 |
./inc/azure_uamqp_c/amqp_definitions_open.h |
| 138 |
./inc/azure_uamqp_c/amqp_definitions_begin.h |
| 139 |
./inc/azure_uamqp_c/amqp_definitions_attach.h |
| 140 |
./inc/azure_uamqp_c/amqp_definitions_flow.h |
| 141 |
./inc/azure_uamqp_c/amqp_definitions_transfer.h |
| 142 |
./inc/azure_uamqp_c/amqp_definitions_disposition.h |
| 143 |
./inc/azure_uamqp_c/amqp_definitions_detach.h |
| 144 |
./inc/azure_uamqp_c/amqp_definitions_end.h |
| 145 |
./inc/azure_uamqp_c/amqp_definitions_close.h |
| 146 |
./inc/azure_uamqp_c/amqp_definitions_sasl_code.h |
| 147 |
./inc/azure_uamqp_c/amqp_definitions_sasl_mechanisms.h |
| 148 |
./inc/azure_uamqp_c/amqp_definitions_sasl_init.h |
| 149 |
./inc/azure_uamqp_c/amqp_definitions_sasl_challenge.h |
| 150 |
./inc/azure_uamqp_c/amqp_definitions_sasl_response.h |
| 151 |
./inc/azure_uamqp_c/amqp_definitions_sasl_outcome.h |
| 152 |
./inc/azure_uamqp_c/amqp_definitions_terminus_durability.h |
| 153 |
./inc/azure_uamqp_c/amqp_definitions_terminus_expiry_policy.h |
| 154 |
./inc/azure_uamqp_c/amqp_definitions_node_properties.h |
| 155 |
./inc/azure_uamqp_c/amqp_definitions_filter_set.h |
| 156 |
./inc/azure_uamqp_c/amqp_definitions_source.h |
| 157 |
./inc/azure_uamqp_c/amqp_definitions_target.h |
| 158 |
./inc/azure_uamqp_c/amqp_definitions_annotations.h |
| 159 |
./inc/azure_uamqp_c/amqp_definitions_message_id_ulong.h |
| 160 |
./inc/azure_uamqp_c/amqp_definitions_message_id_uuid.h |
| 161 |
./inc/azure_uamqp_c/amqp_definitions_message_id_binary.h |
| 162 |
./inc/azure_uamqp_c/amqp_definitions_message_id_string.h |
| 163 |
./inc/azure_uamqp_c/amqp_definitions_address_string.h |
| 164 |
./inc/azure_uamqp_c/amqp_definitions_header.h |
| 165 |
./inc/azure_uamqp_c/amqp_definitions_delivery_annotations.h |
| 166 |
./inc/azure_uamqp_c/amqp_definitions_message_annotations.h |
| 167 |
./inc/azure_uamqp_c/amqp_definitions_application_properties.h |
| 168 |
./inc/azure_uamqp_c/amqp_definitions_data.h |
| 169 |
./inc/azure_uamqp_c/amqp_definitions_amqp_sequence.h |
| 170 |
./inc/azure_uamqp_c/amqp_definitions_amqp_value.h |
| 171 |
./inc/azure_uamqp_c/amqp_definitions_footer.h |
| 172 |
./inc/azure_uamqp_c/amqp_definitions_properties.h |
| 173 |
./inc/azure_uamqp_c/amqp_definitions_received.h |
| 174 |
./inc/azure_uamqp_c/amqp_definitions_accepted.h |
| 175 |
./inc/azure_uamqp_c/amqp_definitions_rejected.h |
| 176 |
./inc/azure_uamqp_c/amqp_definitions_released.h |
| 177 |
./inc/azure_uamqp_c/amqp_definitions_modified.h |
| 178 |
./inc/azure_uamqp_c/amqp_definitions.h |
| 179 |
./inc/azure_uamqp_c/amqp_frame_codec.h |
| 180 |
./inc/azure_uamqp_c/amqp_management.h |
| 181 |
./inc/azure_uamqp_c/amqp_types.h |
| 182 |
./inc/azure_uamqp_c/amqpvalue.h |
| 183 |
./inc/azure_uamqp_c/amqpvalue_to_string.h |
| 184 |
./inc/azure_uamqp_c/async_operation.h |
| 185 |
./inc/azure_uamqp_c/cbs.h |
| 186 |
./inc/azure_uamqp_c/connection.h |
| 187 |
./inc/azure_uamqp_c/frame_codec.h |
| 188 |
./inc/azure_uamqp_c/header_detect_io.h |
| 189 |
./inc/azure_uamqp_c/link.h |
| 190 |
./inc/azure_uamqp_c/message.h |
| 191 |
./inc/azure_uamqp_c/message_receiver.h |
| 192 |
./inc/azure_uamqp_c/message_sender.h |
| 193 |
./inc/azure_uamqp_c/messaging.h |
| 194 |
./inc/azure_uamqp_c/sasl_anonymous.h |
| 195 |
./inc/azure_uamqp_c/sasl_frame_codec.h |
| 196 |
./inc/azure_uamqp_c/sasl_mechanism.h |
| 197 |
./inc/azure_uamqp_c/sasl_server_mechanism.h |
| 198 |
./inc/azure_uamqp_c/sasl_mssbcbs.h |
| 199 |
./inc/azure_uamqp_c/sasl_plain.h |
| 200 |
./inc/azure_uamqp_c/saslclientio.h |
| 201 |
./inc/azure_uamqp_c/sasl_server_io.h |
| 202 |
./inc/azure_uamqp_c/server_protocol_io.h |
| 203 |
./inc/azure_uamqp_c/session.h |
| 204 |
./inc/azure_uamqp_c/socket_listener.h |
| 205 |
./inc/azure_uamqp_c/uamqp.h |
| 206 |
) |
| 207 |
|
| 208 |
set(uamqp_c_files |
| 209 |
./src/amqp_definitions.c |
| 210 |
./src/amqp_frame_codec.c |
| 211 |
./src/amqp_management.c |
| 212 |
./src/amqpvalue.c |
| 213 |
./src/amqpvalue_to_string.c |
| 214 |
./src/async_operation.c |
| 215 |
./src/cbs.c |
| 216 |
./src/connection.c |
| 217 |
./src/frame_codec.c |
| 218 |
./src/header_detect_io.c |
| 219 |
./src/link.c |
| 220 |
./src/message.c |
| 221 |
./src/message_receiver.c |
| 222 |
./src/message_sender.c |
| 223 |
./src/messaging.c |
| 224 |
./src/sasl_anonymous.c |
| 225 |
./src/sasl_frame_codec.c |
| 226 |
./src/sasl_mechanism.c |
| 227 |
./src/sasl_server_mechanism.c |
| 228 |
./src/sasl_mssbcbs.c |
| 229 |
./src/sasl_plain.c |
| 230 |
./src/saslclientio.c |
| 231 |
./src/session.c |
| 232 |
) |
| 233 |
|
| 234 |
if(WIN32) |
| 235 |
set(socketlistener_c_files |
| 236 |
./src/socket_listener_win32.c |
| 237 |
) |
| 238 |
elseif(UNIX) |
| 239 |
set(socketlistener_c_files |
| 240 |
./src/socket_listener_berkeley.c |
| 241 |
) |
| 242 |
else() |
| 243 |
set(socketlistener_c_files |
| 244 |
) |
| 245 |
endif() |
| 246 |
|
| 247 |
add_library(uamqp |
| 248 |
${uamqp_c_files} |
| 249 |
${uamqp_h_files} |
| 250 |
${socketlistener_c_files} |
| 251 |
) |
| 252 |
setTargetBuildProperties(uamqp) |
| 253 |
|
| 254 |
target_link_libraries(uamqp aziotsharedutil) |
| 255 |
|
| 256 |
if (NOT ${skip_samples}) |
| 257 |
add_subdirectory(samples) |
| 258 |
endif() |
| 259 |
|
| 260 |
if (${run_unittests}) |
| 261 |
include("dependencies-test.cmake") |
| 262 |
add_subdirectory(tests) |
| 263 |
endif() |
| 264 |
|
| 265 |
# The following "set" statetement exports across the project a global variable |
| 266 |
set(UAMQP_INC_FOLDER ${CMAKE_CURRENT_LIST_DIR}/inc CACHE INTERNAL "This is the include folder for UAMQP" FORCE) |
| 267 |
set(UAMQP_SRC_FOLDER ${CMAKE_CURRENT_LIST_DIR}/src CACHE INTERNAL "This is the lib folder for UAMQP" FORCE) |
| 268 |
|
| 269 |
# Set CMAKE_INSTALL_LIBDIR if not defined |
| 270 |
include(GNUInstallDirs) |
| 271 |
|
| 272 |
# Install uamqp |
| 273 |
set(package_location "cmake") |
| 274 |
|
| 275 |
if(NOT DEFINED CMAKE_INSTALL_LIBDIR) |
| 276 |
set(CMAKE_INSTALL_LIBDIR "lib") |
| 277 |
endif() |
| 278 |
|
| 279 |
install(TARGETS uamqp EXPORT uamqpTargets |
| 280 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 281 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 282 |
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/../bin |
| 283 |
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/azureiot |
| 284 |
) |
| 285 |
install(FILES ${uamqp_h_files} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/azureiot/azure_uamqp_c) |
| 286 |
|
| 287 |
include(CMakePackageConfigHelpers) |
| 288 |
|
| 289 |
write_basic_package_version_file( |
| 290 |
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" |
| 291 |
VERSION ${UAMQP_VERSION} |
| 292 |
COMPATIBILITY SameMajorVersion |
| 293 |
) |
| 294 |
|
| 295 |
configure_file("configs/${PROJECT_NAME}Config.cmake" |
| 296 |
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" |
| 297 |
COPYONLY |
| 298 |
) |
| 299 |
|
| 300 |
install(EXPORT uamqpTargets |
| 301 |
FILE |
| 302 |
"${PROJECT_NAME}Targets.cmake" |
| 303 |
DESTINATION |
| 304 |
${package_location} |
| 305 |
) |
| 306 |
|
| 307 |
install( |
| 308 |
FILES |
| 309 |
"configs/${PROJECT_NAME}Config.cmake" |
| 310 |
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" |
| 311 |
DESTINATION |
| 312 |
${package_location} |
| 313 |
) |
| 314 |
|
| 315 |
compileTargetAsC99(uamqp) |