forked from nanomsg/nng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
512 lines (430 loc) · 17.1 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#
# Copyright (c) 2012 Martin Sustrik All rights reserved.
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
# Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
# Copyright 2016 Franklin "Snaipe" Mathieu <[email protected]>
# Copyright 2018 Staysail Systems, Inc. <[email protected]>
# Copyright 2018 Capitar IT Group BV <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
cmake_minimum_required (VERSION 3.1)
project (nng C)
include (CheckFunctionExists)
include (CheckSymbolExists)
include (CheckStructHasMember)
include (CheckLibraryExists)
include (CheckCSourceCompiles)
include (CheckCCompilerFlag)
include (CMakeDependentOption)
include (GNUInstallDirs)
include (TestBigEndian)
include (FindUnixCommands)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (POLICY CMP0042)
# Newer cmake on MacOS should use @rpath
cmake_policy (SET CMP0042 NEW)
endif ()
set(CMAKE_C_STANDARD 99)
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
if ("${isSystemDir}" STREQUAL "-1")
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif ("${isSystemDir}" STREQUAL "-1")
set (NNG_DESCRIPTION "High-Performance Scalability Protocols NextGen")
set (ISSUE_REPORT_MSG "Please consider opening an issue at https://github.com/nanomsg/nng")
# Determine library versions.
set (NNG_ABI_SOVERSION 1)
set (NNG_ABI_VERSION "1.0.0")
# Determine package version.
find_package (Git QUIET)
if (DEFINED ENV{TRAVIS_TAG})
set (NNG_PACKAGE_VERSION "$ENV{TRAVIS_TAG}")
elseif (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Working off a git repo, using git versioning
# Get version from last tag
execute_process (
COMMAND "${GIT_EXECUTABLE}" describe --always# | sed -e "s:v::"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE NNG_PACKAGE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# If the sources have been changed locally, add -dirty to the version.
execute_process (
COMMAND "${GIT_EXECUTABLE}" diff --quiet
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
RESULT_VARIABLE res)
if (res EQUAL 1)
set (NNG_PACKAGE_VERSION "${NNG_PACKAGE_VERSION}-dirty")
endif()
else ()
set (NNG_PACKAGE_VERSION "Unknown")
endif()
# User-defined options.
option(BUILD_SHARED_LIBS "Build shared library" ${BUILD_SHARED_LIBS})
if (CMAKE_CROSSCOMPILING)
set (NNG_NATIVE_BUILD OFF)
else()
set (NNG_NATIVE_BUILD ON)
endif()
# We only build command line tools and tests if we are not in a
# cross-compile situation. Cross-compiling users who still want to
# build these must enable them explicitly.
option (NNG_TESTS "Build and run tests" ${NNG_NATIVE_BUILD})
option (NNG_TOOLS "Build extra tools" ${NNG_NATIVE_BUILD})
option (NNG_ENABLE_NNGCAT "Enable building nngcat utility." ${NNG_TOOLS})
option (NNG_ENABLE_COVERAGE "Enable coverage reporting." OFF)
# Enable access to private APIs for our own use.
add_definitions (-DNNG_PRIVATE)
option (NNG_ENABLE_TLS "Enable TLS protocol (requires mbedTLS" OFF)
if (NNG_ENABLE_TLS)
add_definitions(-DNNG_SUPP_TLS)
set(NNG_SUPP_TLS ON)
endif()
option (NNG_ENABLE_HTTP "Enable HTTP API" ON)
if (NNG_ENABLE_HTTP)
set(NNG_SUPP_HTTP ON)
endif()
mark_as_advanced(NNG_ENABLE_HTTP)
option (NNG_ENABLE_STATS "Enable statistics" ON)
if (NNG_ENABLE_STATS)
add_definitions(-DNNG_ENABLE_STATS)
endif()
mark_as_advanced(NNG_ENABLE_STATS)
option (NNG_PROTO_BUS0 "Enable BUSv0 protocol." ON)
if (NNG_PROTO_BUS0)
add_definitions (-DNNG_HAVE_BUS0)
endif ()
mark_as_advanced(NNG_PROTO_BUS0)
option (NNG_PROTO_PAIR0 "Enable PAIRv0 protocol." ON)
if (NNG_PROTO_PAIR0)
add_definitions (-DNNG_HAVE_PAIR0)
endif ()
mark_as_advanced(NNG_PROTO_PAIR0)
option (NNG_PROTO_PAIR1 "Enable PAIRv1 protocol." ON)
if (NNG_PROTO_PAIR1)
add_definitions (-DNNG_HAVE_PAIR1)
endif ()
mark_as_advanced(NNG_PROTO_PAIR1)
option (NNG_PROTO_REQ0 "Enable REQv0 protocol." ON)
if (NNG_PROTO_REQ0)
add_definitions (-DNNG_HAVE_REQ0)
endif ()
mark_as_advanced(NNG_PROTO_REQ0)
option (NNG_PROTO_REP0 "Enable REPv0 protocol." ON)
if (NNG_PROTO_REP0)
add_definitions (-DNNG_HAVE_REP0)
endif ()
mark_as_advanced(NNG_PROTO_REP0)
option (NNG_PROTO_PUB0 "Enable PUBv0 protocol." ON)
if (NNG_PROTO_PUB0)
add_definitions (-DNNG_HAVE_PUB0)
endif ()
mark_as_advanced(NNG_PROTO_PUB0)
option (NNG_PROTO_SUB0 "Enable SUBv0 protocol." ON)
if (NNG_PROTO_SUB0)
add_definitions (-DNNG_HAVE_SUB0)
endif ()
mark_as_advanced(NNG_PROTO_SUB0)
option (NNG_PROTO_PUSH0 "Enable PUSHv0 protocol." ON)
if (NNG_PROTO_PUSH0)
add_definitions (-DNNG_HAVE_PUSH0)
endif ()
mark_as_advanced(NNG_PROTO_PUSH0)
option (NNG_PROTO_PULL0 "Enable PULLv0 protocol." ON)
if (NNG_PROTO_PULL0)
add_definitions (-DNNG_HAVE_PULL0)
endif ()
mark_as_advanced(NNG_PROTO_PULL0)
option (NNG_PROTO_SURVEYOR0 "Enable SURVEYORv0 protocol." ON)
if (NNG_PROTO_SURVEYOR0)
add_definitions (-DNNG_HAVE_SURVEYOR0)
endif ()
mark_as_advanced(NNG_PROTO_SURVEYOR0)
option (NNG_PROTO_RESPONDENT0 "Enable RESPONDENTv0 protocol." ON)
if (NNG_PROTO_RESPONDENT0)
add_definitions (-DNNG_HAVE_RESPONDENT0)
endif ()
mark_as_advanced(NNG_PROTO_RESPONDENT0)
option (NNG_TRANSPORT_INPROC "Enable inproc transport." ON)
if (NNG_TRANSPORT_INPROC)
add_definitions (-DNNG_TRANSPORT_INPROC)
endif ()
mark_as_advanced(NNG_TRANSPORT_INPROC)
option (NNG_TRANSPORT_IPC "Enable IPC transport." ON)
if (NNG_TRANSPORT_IPC)
add_definitions (-DNNG_TRANSPORT_IPC)
endif ()
mark_as_advanced(NNG_TRANSPORT_IPC)
option (NNG_TRANSPORT_TCP "Enable TCP transport." ON)
if (NNG_TRANSPORT_TCP)
add_definitions (-DNNG_TRANSPORT_TCP)
endif ()
mark_as_advanced(NNG_TRANSPORT_TCP)
CMAKE_DEPENDENT_OPTION(NNG_TRANSPORT_TLS "Enable TLS transport" ON
"NNG_ENABLE_TLS" OFF)
if (NNG_TRANSPORT_TLS)
set(NNG_SUPP_TLS ON)
add_definitions (-DNNG_TRANSPORT_TLS)
endif()
mark_as_advanced(NNG_TRANSPORT_TLS)
option (NNG_TRANSPORT_WS "Enable WebSocket transport." ON)
if (NNG_TRANSPORT_WS)
add_definitions (-DNNG_TRANSPORT_WS)
set(NNG_SUPP_WEBSOCKET ON)
endif ()
mark_as_advanced(NNG_TRANSPORT_WS)
CMAKE_DEPENDENT_OPTION(NNG_TRANSPORT_WSS "Enable WSS transport" ON
"NNG_ENABLE_TLS" OFF)
if (NNG_TRANSPORT_WSS)
add_definitions (-DNNG_TRANSPORT_WSS)
set(NNG_SUPP_WEBSOCKET ON)
endif ()
mark_as_advanced(NNG_TRANSPORT_WSS)
option (NNG_TRANSPORT_ZEROTIER "Enable ZeroTier transport (requires libzerotiercore)." OFF)
if (NNG_TRANSPORT_ZEROTIER)
add_definitions (-DNNG_TRANSPORT_ZEROTIER)
endif ()
mark_as_advanced(NNG_TRANSPORT_ZEROTIER)
# dependencies
if (NNG_SUPP_WEBSOCKET)
set(NNG_SUPP_HTTP ON)
set(NNG_SUPP_BASE64 ON)
set(NNG_SUPP_SHA1 ON)
endif()
# Extra defines.
if (NNG_SUPP_TLS)
add_definitions (-DNNG_SUPP_TLS)
endif()
# Platform checks.
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(NNG_WARN_FLAGS "-Wall -Wextra -fno-omit-frame-pointer")
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(NNG_WARN_FLAGS "-Wall -Wextra -fno-omit-frame-pointer")
elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
set(NNG_WARN_FLAGS "-Wall -Wextra -fno-omit-frame-pointer")
endif()
include (CheckSanitizer)
CheckSanitizer()
if (NOT NNG_SANITIZER STREQUAL "none")
set (NNG_SANITIZER_FLAGS "-fsanitize=${NNG_SANITIZER}")
endif()
if (NNG_ENABLE_COVERAGE)
# NB: This only works for GCC and Clang 3.0 and newer. If your stuff
# is older than that, you will need to find something newer. For
# correct reporting, we always turn off all optimizations.
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(NNG_COVERAGE_FLAGS "-g -O0 --coverage")
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(NNG_COVERAGE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
set(NNG_COVERAGE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
else()
message(FATAL_ERROR "Unable to enable coverage for your compiler.")
endif()
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NNG_WARN_FLAGS} ${NNG_COVERAGE_FLAGS} ${NNG_SANITIZER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NNG_WARN_FLAGS} ${NNG_COVERAGE_FLAGS} ${NNG_SANITIZER_FLAGS}")
TEST_BIG_ENDIAN(NNG_BIG_ENDIAN)
if (NNG_BIG_ENDIAN)
add_definitions (-DNNG_BIG_ENDIAN)
else()
add_definitions (-DNNG_LITTLE_ENDIAN)
endif()
# If the compiler is not on Windows, does it support hiding the
# symbols by default? For shared libraries we would like to do this.
if (NOT WIN32 AND NOT CYGWIN)
check_c_compiler_flag(-fvisibility=hidden NNG_HIDDEN_VISIBILITY)
if (NNG_HIDDEN_VISIBILITY)
add_definitions (-DNNG_HIDDEN_VISIBILITY)
endif()
endif()
find_package (Threads REQUIRED)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-DNNG_PLATFORM_LINUX)
add_definitions (-DNNG_USE_EVENTFD)
# Windows subsystem for Linux -- smells like Linux, but it has
# some differences (SO_REUSEADDR for one).
if (CMAKE_SYSTEM_VERSION MATCHES "Microsoft")
add_definitions (-DNNG_PLATFORM_WSL)
endif()
set(NNG_PLATFORM_POSIX ON)
elseif (CMAKE_SYSTEM_NAME MATCHES "Android")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-DNNG_PLATFORM_LINUX)
add_definitions (-DNNG_PLATFORM_ANDROID)
add_definitions (-DNNG_USE_EVENTFD)
set(NNG_PLATFORM_POSIX ON)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-DNNG_PLATFORM_DARWIN)
# macOS 10.12 and later have getentropy, but the older releases
# have ARC4_RANDOM, and that is sufficient to our needs.
add_definitions (-DNNG_USE_ARC4_RANDOM)
# macOS added some of CLOCK_MONOTONIC, but the implementation is
# broken and unreliable, so don't use it.
add_definitions (-DNNG_USE_CLOCKID=CLOCK_REALTIME)
set(NNG_PLATFORM_POSIX ON)
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-DNNG_PLATFORM_FREEBSD)
set(NNG_PLATFORM_POSIX ON)
elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-DNNG_PLATFORM_NETBSD)
set(NNG_PLATFORM_POSIX ON)
elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-DNNG_PLATFORM_OPENBSD)
set(NNG_PLATFORM_POSIX ON)
elseif (CMAKE_SYSTEM_NAME MATCHES "SunOS")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-DNNG_PLATFORM_SUNOS)
set(NNG_PLATFORM_POSIX ON)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions (-DNNG_PLATFORM_WINDOWS)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
add_definitions (-D_CRT_RAND_S)
set(NNG_PLATFORM_WINDOWS ON)
# Target Windows Vista and later
add_definitions (-D_WIN32_WINNT=0x0600)
list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_WIN32_WINNT=0x0600)
elseif (CMAKE_SYSTEM_NAME MATCHES "QNX")
add_definitions (-DNNG_PLATFORM_POSIX)
add_definitions (-D__EXT_BSD)
add_definitions (-D_QNX_SOURCE)
add_definitions (-DNNG_PLATFORM_QNX)
set(NNG_PLATFORM_POSIX ON)
else ()
message (AUTHOR_WARNING "WARNING: This platform may not be supported: ${CMAKE_SYSTEM_NAME}")
message (AUTHOR_WARNING "${ISSUE_REPORT_MSG}")
# blithely hope for POSIX to work
find_package (Threads REQUIRED)
add_definitions (-DPLATFORM_POSIX)
endif ()
macro (nng_check_func SYM DEF)
check_function_exists (${SYM} ${DEF})
if (${DEF})
add_definitions (-D${DEF}=1)
endif ()
endmacro (nng_check_func)
macro (nng_check_sym SYM HDR DEF)
check_symbol_exists (${SYM} ${HDR} ${DEF})
if (${DEF})
add_definitions (-D${DEF}=1)
endif ()
endmacro (nng_check_sym)
macro (nng_check_lib LIB SYM DEF)
check_library_exists (${LIB} ${SYM} "" ${DEF})
if (${DEF})
add_definitions (-D${DEF}=1)
set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} ${LIB})
endif ()
endmacro (nng_check_lib)
macro (nng_check_struct_member STR MEM HDR DEF)
check_struct_has_member ("struct ${STR}" ${MEM} ${HDR} ${DEF})
if (${DEF})
add_definitions (-D${DEF}=1)
endif ()
endmacro (nng_check_struct_member)
if (WIN32)
# Windows is a special snowflake.
set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} ws2_32)
set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} mswsock)
set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} advapi32)
nng_check_sym (InitializeConditionVariable windows.h NNG_HAVE_CONDVAR)
nng_check_sym (snprintf stdio.h NNG_HAVE_SNPRINTF)
if (NOT NNG_HAVE_CONDVAR OR NOT NNG_HAVE_SNPRINTF)
message (FATAL_ERROR
"Modern Windows API support is missing. "
"Versions of Windows prior to Vista are not supported. "
"Further, the 32-bit MinGW environment is not supported. "
"Ensure you have at least Windows Vista or newer, and are "
"using either Visual Studio 2013 or newer or MinGW-W64.")
endif()
else ()
# Unconditionally declare the following feature test macros. These are
# needed for some platforms (glibc and SunOS/illumos) and are harmless
# on the others.
add_definitions (-D_GNU_SOURCE)
add_definitions (-D_REENTRANT)
add_definitions (-D_THREAD_SAFE)
add_definitions (-D_POSIX_PTHREAD_SEMANTICS)
nng_check_func (lockf NNG_HAVE_LOCKF)
nng_check_func (flock NNG_HAVE_FLOCK)
nng_check_lib (rt clock_gettime NNG_HAVE_CLOCK_GETTIME)
nng_check_lib (pthread sem_wait NNG_HAVE_SEMAPHORE_PTHREAD)
nng_check_lib (nsl gethostbyname NNG_HAVE_LIBNSL)
nng_check_lib (socket socket NNG_HAVE_LIBSOCKET)
nng_check_sym (AF_UNIX sys/socket.h NNG_HAVE_UNIX_SOCKETS)
nng_check_sym (backtrace_symbols_fd execinfo.h NNG_HAVE_BACKTRACE)
nng_check_sym (alloca alloca.h NNG_HAVE_ALLOCA)
nng_check_struct_member(msghdr msg_control sys/socket.h NNG_HAVE_MSG_CONTROL)
nng_check_sym (eventfd sys/eventfd NNG_HAVE_EVENTFD)
nng_check_sym (kqueue sys/event.h NNG_HAVE_KQUEUE)
nng_check_sym (port_create port.h NNG_HAVE_PORT_CREATE)
nng_check_sym (epoll_create sys/epoll.h NNG_HAVE_EPOLL)
nng_check_sym (epoll_create1 sys/epoll.h NNG_HAVE_EPOLL_CREATE1)
nng_check_sym (getpeereid unistd.h NNG_HAVE_GETPEEREID)
nng_check_sym (SO_PEERCRED sys/socket.h NNG_HAVE_SOPEERCRED)
nng_check_struct_member (sockpeercred uid sys/socket.h NNG_HAVE_SOCKPEERCRED)
nng_check_sym (LOCAL_PEERCRED sys/un.h NNG_HAVE_LOCALPEERCRED)
nng_check_sym (getpeerucred ucred.h NNG_HAVE_GETPEERUCRED)
nng_check_sym (atomic_flag_test_and_set stdatomic.h NNG_HAVE_STDATOMIC)
endif ()
nng_check_sym (strlcat string.h NNG_HAVE_STRLCAT)
nng_check_sym (strlcpy string.h NNG_HAVE_STRLCPY)
nng_check_sym (strnlen string.h NNG_HAVE_STRNLEN)
nng_check_sym (strcasecmp string.h NNG_HAVE_STRCASECMP)
nng_check_sym (strncasecmp string.h NNG_HAVE_STRNCASECMP)
# Set a static symbol. We do this for testing, so that tests can
# be skipped if they would rely on symbols that might not be exported.
# For example, idhash depends on private symbols, so don't test it
# when using a shared library on Windows because the symbols won't
# resolve.
if (NOT(BUILD_SHARED_LIBS))
set (NNG_STATIC_LIB ON)
message(STATUS "Building static libs")
endif()
add_subdirectory (src)
if (NNG_TESTS)
enable_testing()
set(all_tests, "")
add_subdirectory (tests)
add_subdirectory (perf)
endif()
# Build the tools
if (NNG_ENABLE_NNGCAT)
add_subdirectory (tools/nngcat)
endif ()
add_subdirectory (docs/man)
set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
set (CPACK_PACKAGE_VERSION ${NNG_PACKAGE_VERSION})
set (CPACK_PACKAGE_CONTACT "[email protected]")
set (CPACK_PACKAGE_VENDOR "nanomsg.org")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "nanomsg next generation library")
set (CPACK_SOURCE_GENERATOR "TBZ2;TGZ;ZIP")
set (CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}")
set (CPACK_SOURCE_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${NNG_PACKAGE_VERSION}-src")
set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
set (CPACK_PACKAGE_INSTALL_DIRECTORY "nng")
set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${NNG_PACKAGE_VERSION}")
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
include (CPack)