forked from Azure/azure-uamqp-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
202 lines (172 loc) · 6.53 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
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
cmake_minimum_required(VERSION 2.8.11)
project(uamqp)
#making a nice global variable to know if we are on linux or not.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(LINUX TRUE)
#on Linux, enable valgrind
#these commands (MEMORYCHECK...) need to apear BEFORE include(CTest) or they will not have any effect
find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full --error-exitcode=1 --track-origins=yes")
endif()
include (CTest)
option(run_e2e_tests "set run_e2e_tests to ON to run e2e tests (default is OFF) [if possible, they are always build]" OFF)
option(run_longhaul_tests "set run_longhaul_tests to ON to run longhaul tests (default is OFF)[if possible, they are always build]" OFF)
option(skip_unittests "set skip_unittests to ON to skip unittests (default is OFF)[if possible, they are always build]" OFF)
option(leak_detection "set leak_detection to ON (default is OFF)" OFF)
option(compileOption_C "passes a string to the command line of the C compiler" OFF)
option(compileOption_CXX "passes a string to the command line of the C++ compiler" OFF)
option(use_wsio "set use_wsio to ON to use libwebsockets for WebSocket support (default is OFF)" OFF)
if(WIN32)
option(use_schannel "set use_schannel to ON if schannel is to be used, set to OFF to not use schannel" ON)
option(use_openssl "set use_openssl to ON if openssl is to be used, set to OFF to not use openssl" OFF)
option(use_wolfssl "set use_wolfssl to ON if wolfssl is to be used, set to OFF to not use wolfssl" OFF)
else()
option(use_schannel "set use_schannel to ON if schannel is to be used, set to OFF to not use schannel" OFF)
option(use_openssl "set use_openssl to ON if openssl is to be used, set to OFF to not use openssl" ON)
option(use_wolfssl "set use_wolfssl to ON if wolfssl is to be used, set to OFF to not use wolfssl" OFF)
endif()
#Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_definitions(-DREFCOUNT_ATOMIC_DONTCARE)
add_definitions(-D__STDC_NO_ATOMICS__=1)
if(${use_wsio})
include_directories(libwebsockets/lib)
include_directories(${PROJECT_BINARY_DIR}/libwebsockets)
add_subdirectory(libwebsockets)
endif()
add_subdirectory(azure-c-shared-utility)
enable_testing()
#if any compiler has a command line switch called "OFF" then it will need special care
if(NOT "${compileOption_C}" STREQUAL "OFF")
set(CMAKE_C_FLAGS "${compileOption_C} ${CMAKE_C_FLAGS}")
endif()
if(NOT "${compileOption_CXX}" STREQUAL "OFF")
set(CMAKE_CXX_FLAGS "${compileOption_CXX} ${CMAKE_CXX_FLAGS}")
endif()
#this project uses several other projects that are build not by these CMakeFiles
#this project also targets several OSes
#this function takes care of three things:
#1. copying some shared libraries(.dll or .so) to the location of the output executable
macro(compileAsC99)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "--std=c99 ${CMAKE_C_FLAGS}")
set (CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}")
endif()
else()
set (CMAKE_C_STANDARD 99)
set (CMAKE_CXX_STANDARD 11)
endif()
endmacro(compileAsC99)
macro(compileAsC11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "--std=c11 ${CMAKE_C_FLAGS}")
set (CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L ${CMAKE_C_FLAGS}")
set (CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}")
endif()
else()
set (CMAKE_C_STANDARD 11)
set (CMAKE_CXX_STANDARD 11)
endif()
endmacro(compileAsC11)
option(memory_trace "set memory_trace to ON if memory usage is to be used, set to OFF to not use it" ON)
include_directories(${CMAKE_CURRENT_LIST_DIR}/inc ${SHARED_UTIL_INC_FOLDER})
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if(${leak_detection})
add_definitions(-D_CRTDBG_MAP_ALLOC)
endif()
if(${memory_trace})
else()
add_definitions(-DDISABLE_MEMORY_TRACE)
endif()
if(WIN32)
include_directories($ENV{OpenSSLDir}/include)
endif()
set(uamqp_h_files
./inc/azure_uamqp_c/amqp_definitions.h
./inc/azure_uamqp_c/amqp_frame_codec.h
./inc/azure_uamqp_c/amqp_management.h
./inc/azure_uamqp_c/amqp_types.h
./inc/azure_uamqp_c/amqpalloc.h
./inc/azure_uamqp_c/amqpvalue.h
./inc/azure_uamqp_c/amqpvalue_to_string.h
./inc/azure_uamqp_c/cbs.h
./inc/azure_uamqp_c/connection.h
./inc/azure_uamqp_c/consolelogger.h
./inc/azure_uamqp_c/frame_codec.h
./inc/azure_uamqp_c/header_detect_io.h
./inc/azure_uamqp_c/link.h
./inc/azure_uamqp_c/logger.h
./inc/azure_uamqp_c/message.h
./inc/azure_uamqp_c/message_receiver.h
./inc/azure_uamqp_c/message_sender.h
./inc/azure_uamqp_c/messaging.h
./inc/azure_uamqp_c/sasl_anonymous.h
./inc/azure_uamqp_c/sasl_frame_codec.h
./inc/azure_uamqp_c/sasl_mechanism.h
./inc/azure_uamqp_c/sasl_mssbcbs.h
./inc/azure_uamqp_c/sasl_plain.h
./inc/azure_uamqp_c/saslclientio.h
./inc/azure_uamqp_c/session.h
./inc/azure_uamqp_c/socket_listener.h
)
set(uamqp_c_files
./src/amqp_definitions.c
./src/amqp_frame_codec.c
./src/amqp_management.c
./src/amqpalloc.c
./src/amqpvalue.c
./src/amqpvalue_to_string.c
./src/cbs.c
./src/connection.c
./src/consolelogger.c
./src/frame_codec.c
./src/header_detect_io.c
./src/link.c
./src/message.c
./src/message_receiver.c
./src/message_sender.c
./src/messaging.c
./src/sasl_anonymous.c
./src/sasl_frame_codec.c
./src/sasl_mechanism.c
./src/sasl_mssbcbs.c
./src/sasl_plain.c
./src/saslclientio.c
./src/session.c
)
if(${use_wsio})
set(wsio_h_files
./inc/azure_uamqp_c/wsio.h
)
set(wsio_c_files
./src/wsio.c
)
else()
set(wsio_h_files)
set(wsio_c_files)
endif()
if(WIN32)
set(socketlistener_c_files
./src/socket_listener_win32.c
)
else()
set(socketlistener_c_files)
endif()
add_library(uamqp
${uamqp_c_files}
${uamqp_h_files}
${wsio_c_files}
${wsio_h_files}
${socketlistener_c_files}
)
add_subdirectory(samples)
if (NOT ${skip_unittests})
add_subdirectory(tests)
endif()
# The following "set" statetement exports across the project a global variable
set(UAMQP_INC_FOLDER ${CMAKE_CURRENT_LIST_DIR}/inc CACHE INTERNAL "This is the include folder for UAMQP" FORCE)
set(UAMQP_SRC_FOLDER ${CMAKE_CURRENT_LIST_DIR}/src CACHE INTERNAL "This is the lib folder for UAMQP" FORCE)