forked from zeromq/ingescape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
684 lines (592 loc) · 28.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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
# CMake build script for Ingescape
# ##############################################################################
# Project setup
# ##############################################################################
cmake_minimum_required(VERSION 3.16)
option(WITH_CSHARP_WRAPPER "Compile the library with CSHARP Binding" OFF)
if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Minimum OS X deployment version")
set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/")
set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}")
endif(APPLE)
option(OSX_UNIVERSAL "Build for both arm64 and x86_64" OFF)
if(OSX_UNIVERSAL)
message(STATUS "Building for arm64 and x86_64")
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build universal binaries")
endif(OSX_UNIVERSAL)
# Add path to custom macro
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/modules/library")
# Include custom helpers
include(IngescapeHelper)
include(IdentifyOS)
# gets version from admin.c file
get_ingescape_version(INGESCAPE_VERSION_MAJOR INGESCAPE_VERSION_MINOR INGESCAPE_VERSION_PATCH)
set(INGESCAPE_VERSION "${INGESCAPE_VERSION_MAJOR}.${INGESCAPE_VERSION_MINOR}.${INGESCAPE_VERSION_PATCH}")
message(STATUS "Detected INGESCAPE Version - ${INGESCAPE_VERSION}")
project(ingescape VERSION ${INGESCAPE_VERSION} HOMEPAGE_URL https://ingescape.com LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
ADD_DEFINITIONS (-DZYRE_BUILD_DRAFT_API)
ADD_DEFINITIONS (-DCZMQ_BUILD_DRAFT_API)
ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API)
# Define the PIC compilation flag
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Option to only generate dependencies.
# Used to setup developmenent environment.
option(DEPS_ONLY "Only generate dependencies" OFF)
# Override default release flags to not define NDEBUG, which CMake sets by default for Release builds
# NB: The NDEBUG flag compile out all assert() calls, skipping whatever was done in the assert call (function call, computation, etc.)
# It changes the compiled code from the source code and we don't want that.
set(CMAKE_C_FLAGS_RELEASE "-O3")
# Check C compiler flags but not on MSVC
if(NOT MSVC)
include(CheckCCompilerFlag)
foreach(_CCOPT
-pedantic
-Wall
-Wextra
-W
-Wpointer-arith
-Wwrite-strings
-Wunused
-Wshadow
-Winline
-Wnested-externs
-Wno-long-long
-Wfloat-equal
-Wno-multichar
-Wsign-compare
-Wundef
-Wno-format-nonliteral
-Wendif-labels
-Wstrict-prototypes
-Wstrict-aliasing=3
-Wcast-align
-Wtype-limits
-Wold-style-declaration
-Wmissing-parameter-type
-Wempty-body
-Wclobbered
-Wignored-qualifiers
-Wconversion
-Wno-sign-conversion
-Wvla
-Wdouble-promotion
-Wno-system-headers
-Wno-pedantic-ms-format)
# surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new
# test result in.
check_c_compiler_flag(${_CCOPT} OPT${_CCOPT})
if(OPT${_CCOPT})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}")
endif()
endforeach()
endif()
# ##############################################################################
# Source files
# ##############################################################################
list(APPEND ingescape_sources
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_admin.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_channels.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_core.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_definition.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_json_node.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_json.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_mapping.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_model.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_monitor.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_network.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_parser.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_performance.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_replay.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_service.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igs_split.c
${CMAKE_CURRENT_SOURCE_DIR}/src/igsagent.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_alloc.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_buf.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_encode.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_gen.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_lex.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_parser.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_tree.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl_version.c
${CMAKE_CURRENT_SOURCE_DIR}/src/yajl.c
$<$<BOOL:${WIN32}>:${CMAKE_CURRENT_BINARY_DIR}/version.rc>
)
source_group("Source Files" FILES ${ingescape_sources})
# ##############################################################################
# Header files
# ##############################################################################
#FIXME: verify that this section is still usefull
set(ingescape_headers_to_install
${CMAKE_CURRENT_SOURCE_DIR}/include/ingescape.h
${CMAKE_CURRENT_SOURCE_DIR}/include/igsagent.h
${CMAKE_CURRENT_SOURCE_DIR}/include/ingescape_private.h
)
set(ingescape_private_headers
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/libut.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/ringbuf.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/utarray.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/uthash.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/utlist.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/utmm.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/utringbuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/utstring.h
${CMAKE_CURRENT_SOURCE_DIR}/src/uthash/utvector.h
)
source_group("Header Files" FILES ${ingescape_private_headers} ${ingescape_headers_to_install})
########################################################################
# Dependencies
########################################################################
message(STATUS "Adding dependencies...")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
option (WITH_DEPS "Build the ZeroMQ stack instead of using the one installed" OFF)
if (WITH_DEPS)
# Force any static library to link against the static version of its dependencies in the stack
set(STATIC_ZMQ_LINK ON)
#sodium
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/sodium)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/sodium/src/libsodium/include)
#zeromq
set(WITH_TLS OFF CACHE BOOL "Use TLS for WSS support")
set(WITH_LIBSODIUM ON CACHE BOOL "Use libsodium instead of built-in tweetnacl")
set(ENABLE_DRAFTS ON CACHE BOOL "Build and install draft classes and methods")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libzmq)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libzmq/include)
add_dependencies(libzmq sodium)
#czmq
set(WITH_DISTCLEAN OFF CACHE BOOL "Dis/Enable 'distclean' targets")
set(CZMQ_WITH_LIBMICROHTTPD OFF CACHE BOOL "Build czmq with libmicrohttpd")
set(CZMQ_WITH_LZ4 OFF CACHE BOOL "Build czmq with lz4")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/czmq)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/czmq/include)
add_dependencies(czmq libzmq)
#zyre
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zyre)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zyre/include)
add_dependencies(zyre czmq)
else ()
find_package(libsodium REQUIRED)
find_package(ZeroMQ 4.3.3 REQUIRED)
find_package(czmq 4.2.1 REQUIRED)
find_package(zyre 2.0.1 REQUIRED)
endif ()
if (APPLE)
find_library(CORE_FRAMEWORK CoreFoundation)
endif (APPLE)
if (NOT DEPS_ONLY)
# ##############################################################################
# library
# ##############################################################################
option(INGESCAPE_BUILD_SHARED "Whether or not to build the shared object" ON)
option(INGESCAPE_BUILD_STATIC "Whether or not to build the static archive" ON)
if(NOT INGESCAPE_BUILD_SHARED AND NOT INGESCAPE_BUILD_STATIC)
message(FATAL_ERROR "Neither static nor shared library build enabled")
endif()
if(NOT MSVC)
# avoid building everything twice for shared + static only on *nix, as Windows
# needs different preprocessor defines in static builds
#FIXME This is a good idea but it's not used anymore. Let's fix that!
#add_library(ingescape_objects OBJECT ${ingescape_sources})
#set_property(TARGET ingescape_objects PROPERTY POSITION_INDEPENDENT_CODE ON)
else()
# WIN32_LIB_FILEFLAGS is used in the RC file that will register the DLL version
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(WIN32_LIB_FILEFLAGS "0")
else ()
set(WIN32_LIB_FILEFLAGS "VS_FF_DEBUG")
endif()
endif()
# shared
if(INGESCAPE_BUILD_SHARED)
add_library(${PROJECT_NAME} SHARED ${ingescape_sources})
if (WITH_DEPS)
add_dependencies(${PROJECT_NAME} zyre)
target_link_libraries(${PROJECT_NAME} PRIVATE sodium)
target_link_libraries(${PROJECT_NAME} PRIVATE libzmq)
target_link_libraries(${PROJECT_NAME} PRIVATE czmq)
target_link_libraries(${PROJECT_NAME} PRIVATE zyre)
else ()
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBSODIUM_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE libzmq)
target_include_directories(${PROJECT_NAME} PRIVATE ${ZeroMQ_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE czmq)
target_include_directories(${PROJECT_NAME} PRIVATE ${CZMQ_PUBLIC_HEADERS_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE zyre)
target_include_directories(${PROJECT_NAME} PRIVATE ${zyre_INCLUDES_DIR})
endif ()
# OS specifig target properties
if(MSVC)
# WIN32_LIB_FILETYPE is used in the RC file that will register the DLL version
set(WIN32_LIB_FILETYPE "VFT_DLL")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/modules/library/library_version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
set_target_properties(${PROJECT_NAME}
PROPERTIES
OUTPUT_NAME_RELEASE "ingescape"
OUTPUT_NAME_DEBUG "ingescaped"
)
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
if (${BITS} EQUAL 64)
install(DIRECTORY dependencies/windows/vcredist/ DESTINATION ressources FILES_MATCHING PATTERN "*64.exe")
else()
install(DIRECTORY dependencies/windows/vcredist/ DESTINATION ressources FILES_MATCHING PATTERN "*86.exe")
endif()
else(MSVC)
set_target_properties(${PROJECT_NAME}
PROPERTIES
#PUBLIC_HEADER "${ingescape_headers_to_install}"
#TODO We do not generate a Framework yet.
#FRAMEWORK TRUE
#FRAMEWORK_VERSION C
#MACOSX_FRAMEWORK_IDENTIFIER com.ingescape
#XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "MyAccount Developer"
VERSION "${INGESCAPE_VERSION}" # Current version
SOVERSION "${INGESCAPE_VERSION_MAJOR}.0.0" # Compatibility version
OUTPUT_NAME "ingescape"
PREFIX "lib"
)
endif(MSVC)
# Add compilation #defines to the target
target_compile_definitions(${PROJECT_NAME} PRIVATE INGESCAPE_EXPORTS=1;TARGET_OS_IOS=0)
# Add linked dependencies
#FIXME All private here ?
target_link_libraries(${PROJECT_NAME}
PRIVATE
$<$<BOOL:${APPLE}>:${CORE_FRAMEWORK}>
$<$<BOOL:${WIN32}>:ws2_32>
)
# Header files
target_include_directories(${PROJECT_NAME}
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
$<$<BOOL:${UNIX}>:${CMAKE_INSTALL_PREFIX}/src>
$<$<BOOL:${WIN32}>:${CMAKE_CURRENT_SOURCE_DIR}/packaging/windows/unix>
$<$<BOOL:${WIN32}>:${CMAKE_INSTALL_PREFIX}/include>
)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
COMPONENT library
FRAMEWORK DESTINATION "Frameworks" # .framework file
COMPONENT library
PUBLIC_HEADER DESTINATION include
COMPONENT library
LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file
COMPONENT library
ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file
COMPONENT library
RUNTIME DESTINATION "lib${LIB_SUFFIX}" # .dll file
COMPONENT library)
endif()
# static
if(INGESCAPE_BUILD_STATIC)
add_library(${PROJECT_NAME}-static STATIC ${ingescape_sources})
target_compile_definitions(${PROJECT_NAME}-static PUBLIC INGESCAPE_STATIC)
if (WITH_DEPS)
add_dependencies(${PROJECT_NAME}-static zyre)
target_link_libraries(${PROJECT_NAME}-static PRIVATE sodium-static)
target_link_libraries(${PROJECT_NAME}-static PRIVATE libzmq-static)
target_link_libraries(${PROJECT_NAME}-static PRIVATE czmq-static)
target_link_libraries(${PROJECT_NAME}-static PRIVATE zyre-static)
else ()
target_link_libraries(${PROJECT_NAME}-static PRIVATE ${LIBSODIUM_LIBRARIES})
target_include_directories(${PROJECT_NAME}-static PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}-static PRIVATE libzmq-static)
target_include_directories(${PROJECT_NAME}-static PRIVATE ${ZeroMQ_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME}-static PRIVATE czmq-static)
target_include_directories(${PROJECT_NAME}-static PRIVATE ${CZMQ_PUBLIC_HEADERS_DIR})
target_link_libraries(${PROJECT_NAME}-static PRIVATE zyre-static)
target_include_directories(${PROJECT_NAME}-static PRIVATE ${zyre_INCLUDES_DIR})
endif ()
# OS specifig target properties
if(MSVC)
# WIN32_LIB_FILETYPE is used in the RC file that will register the DLL version
set(WIN32_LIB_FILETYPE "VFT_STATIC_LIB")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/modules/library/library_version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
target_sources(${PROJECT_NAME}-static PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
set_target_properties(${PROJECT_NAME}-static
PROPERTIES
OUTPUT_NAME_RELEASE "libingescape"
OUTPUT_NAME_DEBUG "libingescaped")
else(MSVC)
set_target_properties(${PROJECT_NAME}-static
PROPERTIES
OUTPUT_NAME "ingescape"
PREFIX "lib")
endif(MSVC)
# Add compilation #defines to the target
target_compile_definitions(${PROJECT_NAME}-static PRIVATE INGESCAPE_EXPORTS=1;TARGET_OS_IOS=0)
# Add linked dependencies
#FIXME All private here ?
target_link_libraries(${PROJECT_NAME}-static
PRIVATE
$<$<BOOL:${APPLE}>:${CORE_FRAMEWORK}>
$<$<BOOL:${WIN32}>:ws2_32>
)
# Header files
target_include_directories(${PROJECT_NAME}-static
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
$<$<BOOL:${UNIX}>:${CMAKE_INSTALL_PREFIX}/src>
$<$<BOOL:${WIN32}>:${CMAKE_CURRENT_SOURCE_DIR}/packaging/windows/unix>
$<$<BOOL:${WIN32}>:${CMAKE_INSTALL_PREFIX}/include>
)
# Release build compile with -O2 flag
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
if(MSVC)
target_compile_options(${PROJECT_NAME}-static PRIVATE "/O2")
else()
target_compile_options(${PROJECT_NAME}-static PRIVATE "-O2")
endif()
endif()
install(TARGETS ${PROJECT_NAME}-static
EXPORT ${PROJECT_NAME}-targets
LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file
COMPONENT library
ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file
COMPONENT library
RUNTIME DESTINATION "lib${LIB_SUFFIX}" # .dll file
COMPONENT library)
endif()
if(WITH_CSHARP_WRAPPER AND WIN32)
add_subdirectory(${CMAKE_SOURCE_DIR}/bindings/csharp)
if (WITH_CSHARP_TEST)
add_dependencies(igstester ${CMAKE_PROJECT_NAME})
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(_INGESCAPE_SUFFIX "d")
set(_LIBZMQ_NAME "libzmq-v142-mt-gd-4_3_5")
else()
set(_INGESCAPE_SUFFIX "")
set(_LIBZMQ_NAME "libzmq-v142-mt-4_3_5")
endif()
add_custom_command(TARGET ${CMAKE_PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bindings/csharp/test/${CMAKE_BUILD_TYPE}/net472/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/ingescape${_INGESCAPE_SUFFIX}.dll ${CMAKE_BINARY_DIR}/bindings/csharp/test/${CMAKE_BUILD_TYPE}/net472/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/dependencies/sodium/${CMAKE_BUILD_TYPE}/libsodium.dll ${CMAKE_BINARY_DIR}/bindings/csharp/test/${CMAKE_BUILD_TYPE}/net472/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/dependencies/libzmq/bin/${CMAKE_BUILD_TYPE}/${_LIBZMQ_NAME}.dll ${CMAKE_BINARY_DIR}/bindings/csharp/test/${CMAKE_BUILD_TYPE}/net472/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/dependencies/czmq/${CMAKE_BUILD_TYPE}/libczmq.dll ${CMAKE_BINARY_DIR}/bindings/csharp/test/${CMAKE_BUILD_TYPE}/net472/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/dependencies/zyre/${CMAKE_BUILD_TYPE}/libzyre.dll ${CMAKE_BINARY_DIR}/bindings/csharp/test/${CMAKE_BUILD_TYPE}/net472/
)
endif ()
endif()
# Install public include files
install(FILES ${ingescape_headers_to_install}
DESTINATION include/ingescape
COMPONENT library)
# ##############################################################################
# Tests
# ##############################################################################
add_subdirectory(test)
# ##############################################################################
# pkgconfig
# ##############################################################################
set(VERSION "${INGESCAPE_VERSION}")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/lib${LIB_SUFFIX}")
set(includedir "\${prefix}/include")
set(pkg_config_defines "")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/libingescape.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/libingescape.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libingescape.pc"
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
COMPONENT library)
# ##############################################################################
# installation
# ##############################################################################
include(CMakePackageConfigHelpers)
if (WIN32)
set(INGESCAPE_CMAKECONFIG_INSTALL_DIR "CMake" CACHE STRING "install path for ingescapeConfig.cmake")
else()
set(INGESCAPE_CMAKECONFIG_INSTALL_DIR "share/cmake/ingescape" CACHE STRING "install path for ingescapeConfig.cmake")
endif(WIN32)
# Export ingescapeTargets.cmake
export(EXPORT ${PROJECT_NAME}-targets FILE "${CMAKE_CURRENT_BINARY_DIR}/ingescapeTargets.cmake")
# Generate ingescapeConfig.cmake
configure_package_config_file(
builds/cmake/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ingescapeConfig.cmake"
INSTALL_DESTINATION ${INGESCAPE_CMAKECONFIG_INSTALL_DIR}
)
# Generate ingescapeConfigVersion.cmake
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ingescapeConfigVersion.cmake
VERSION ${INGESCAPE_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Install CMake config and target files
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ingescapeConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ingescapeConfigVersion.cmake
DESTINATION ${INGESCAPE_CMAKECONFIG_INSTALL_DIR})
install(EXPORT ${PROJECT_NAME}-targets
FILE ingescapeTargets.cmake
DESTINATION ${INGESCAPE_CMAKECONFIG_INSTALL_DIR})
# uninstall target
if(NOT TARGET uninstall)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE
@ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
# ##############################################################################
# installer
# ##############################################################################
# Package installer for release build only
option(PACK_TGZ "Force pack ingescape as a TGZ and not a .deb package" OFF)
if (${CMAKE_OS_NAME} MATCHES "Debian" AND NOT ${PACK_TGZ})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake")
include(Packing-debian)
elseif((WIN32) OR (${CMAKE_BUILD_TYPE} STREQUAL "Release"))
#https://cmake.org/cmake/help/v3.16/module/CPack.html#
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME} core library")
set(CPACK_PACKAGE_DESCRIPTION "${PROJECT_NAME} core library")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://ingescape.com")
set(CPACK_PACKAGE_VENDOR "Ingenuity IO")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_VERSION ${INGESCAPE_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR "${INGESCAPE_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${INGESCAPE_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${INGESCAPE_VERSION_PATCH}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_STRIP_FILES TRUE)
set(
CPACK_SOURCE_IGNORE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/bindings/;${CMAKE_CURRENT_SOURCE_DIR}/build/;${CMAKE_CURRENT_SOURCE_DIR}/.git/;${CMAKE_CURRENT_SOURCE_DIR}/doc/;${CMAKE_CURRENT_SOURCE_DIR}/applications/;${CMAKE_CURRENT_SOURCE_DIR}/ingeprobe/;${CMAKE_CURRENT_SOURCE_DIR}/packaging/"
)
if(WIN32)
# Installers for 32- vs. 64-bit CMake: - Root install directory (displayed to
# end user at installer-run time) - "NSIS package/display name" (text used in
# the installer GUI) - Registry key used to store info about the installation
if(CMAKE_CL_64)
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_NSIS_PACKAGE_NAME
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} (Win64)")
else()
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
set(CPACK_NSIS_PACKAGE_NAME
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} (Win32)")
endif()
if(WITH_CSHARP_WRAPPER)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/bindings/csharp/${CMAKE_BUILD_TYPE}/netstandard2.0/IngescapeCSharp.dll"
DESTINATION lib
)
endif()
# NSIS configuration for Windows see https://cmake.org/cmake/help/v3.14/cpack_
# gen/nsis.html#cpack_gen:CPack%20NSIS%20Generator
set(CPACK_NSIS_DISPLAY_NAME "${PROJECT_NAME} core library")
set(CPACK_NSIS_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_NSIS_HELP_LINK "https://ingescape.com")
set(CPACK_NSIS_CONTACT "[email protected]")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_URL_INFO_ABOUT ${CMAKE_PROJECT_HOMEPAGE_URL})
set(CPACK_NSIS_MENU_LINKS ${CMAKE_PROJECT_HOMEPAGE_URL} "IngeScape Web Site")
set(CPACK_MONOLITHIC_INSTALL ON)
set(CPACK_GENERATOR "NSIS;ZIP")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/README.txt
"The bin directory is empty after installation on purpose.\r\n"
"It will contain agents' executables once installed.")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/README.txt
DESTINATION bin
COMPONENT library)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# https://cmake.org/cmake/help/git-stage/cpack_gen/productbuild.html
# Without component productbuild will not package any files
set(CPACK_COMPONENTS_ALL library)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
set(CPACK_SYSTEM_NAME "macos")
#set(CPACK_PRODUCTBUILD_IDENTITY_NAME "Developer ID Installer: Ingenuity i/o (56DRT9MG9S)")
#set(CPACK_PRODUCTBUILD_KEYCHAIN_PATH "$ENV{HOME}/Library/Keychains/login.keychain")
#set(CPACK_PKGBUILD_IDENTITY_NAME "Developer ID Installer: Ingenuity i/o (56DRT9MG9S)")
#set(CPACK_PKGBUILD_KEYCHAIN_PATH "$ENV{HOME}/Library/Keychains/login.keychain")
set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/packaging/macos/WELCOME.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/packaging/macos/README.txt")
# Without extention productbuild will crash So we just copy License file in
# build folder with an extension
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
"${CMAKE_BINARY_DIR}/LICENSE.txt" COPYONLY)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE.txt")
set(CPACK_PREFLIGHT_LIBRARY_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/builds/xcode/preflight.sh")
set(CPACK_POSTFLIGHT_LIBRARY_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/builds/xcode/postflight.sh")
set(CPACK_GENERATOR "productbuild")
else()
set(CPACK_MONOLITHIC_INSTALL ON)
#FIXME TODO Define a strategy for dependencies for linux
if(ANDROID)
set(CPACK_GENERATOR "ZIP")
else()
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/packaging/unix/install_script.sh"
DESTINATION "."
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT library)
set(CPACK_GENERATOR "TGZ")
endif()
endif()
if(MSVC)
if( ${BITS} EQUAL 64)
set(CPACK_NSIS_WINDOWS_ARCH "x64")
else()
set(CPACK_NSIS_WINDOWS_ARCH "x32")
endif(${BITS} EQUAL 64)
endif(MSVC)
include(CPack)
endif()
endif (NOT DEPS_ONLY)
# ##############################################################################
# summary
# ##############################################################################
message("")
message(STATUS "******************* Configuration Summary *******************")
message(STATUS "General:")
message(STATUS " Version : ${VERSION}")
message(STATUS " System : ${CMAKE_SYSTEM_NAME}")
message(STATUS " C compiler : ${CMAKE_C_COMPILER}")
message(
STATUS " Debug C flags : ${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS}")
message(
STATUS " Release C flags : ${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS}")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Static build : ${INGESCAPE_BUILD_STATIC}")
message(STATUS " Shared build : ${INGESCAPE_BUILD_SHARED}")
message(STATUS "")
message(STATUS "Dependencies:")
include(FeatureSummary)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
message(STATUS "")
message(STATUS "Install:")
message(STATUS " Install prefix : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "")
if(NOT MSVC)
message(
STATUS "*************************************************************")
message(STATUS "Configuration complete! Now procced with:")
message(STATUS " 'make' compile the project")
message(
STATUS
" 'make install' install the project to ${CMAKE_INSTALL_PREFIX}")
message(
STATUS
" 'make uninstall' uninstall the project from ${CMAKE_INSTALL_PREFIX}"
)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS " 'make package' Create library installer")
message(STATUS " 'make package_source' Create source installer")
endif()
endif()
message(STATUS "")