-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
642 lines (555 loc) · 20.6 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
cmake_minimum_required(VERSION 3.13.0)
project(Showtime VERSION 0.27.1)
set(AUTHORS "Byron Mallett")
set(COMPANY "Victoria University of Wellington")
set(DESCRIPTION "Showtime dataflow network library")
set(REPO_URL "https://github.com/mystfit/Showtime-cpp.git")
set(LICENSE_FILE "${CMAKE_SOURCE_DIR}/LICENSE.md")
set(TAGS
dataflow
network
)
set(SHOWTIME_NAMESPACE "${PROJECT_NAME}::")
# Use C17
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Set CMake vars
set(CMAKE_FIND_FRAMEWORKS LAST)
set(CMAKE_DEBUG_POSTFIX d)
set(CMAKE_SUPPRESS_REGENERATION true)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Search packages for host system instead of packages for target system
# in case of cross compilation these macro should be defined by toolchain file
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif()
if(NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif()
# Set platform flags
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
MESSAGE(STATUS "Platform is OSX")
endif()
if(${CMAKE_SYSTM_NAME} MATCHES "Android")
set(ANDROID TRUE)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
MESSAGE(STATUS "Platform is Linux")
endif()
if(LINUX OR MACOSX)
if(NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_SYSTEM_PREFIX_PATH} "/usr/local")
if(LINUX)
list(APPEND CMAKE_PREFIX_PATH "/home/linuxbrew/.linuxbrew")
endif()
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
MESSAGE(STATUS "Platform is Windows")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:__cplusplus")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
option(WINDOWS_USE_DLL_RUNTIME "Use the Visual C++ DLL runtime" ON)
if(WINDOWS_USE_DLL_RUNTIME)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(Boost_USE_STATIC_RUNTIME OFF)
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(Boost_USE_STATIC_RUNTIME ON)
endif()
if(MSVC)
option(ADD_GENERATED_MSVC_PROJECTS "Add generated projects to the CMake solution" ON)
endif()
endif()
# Set build locations
set(CMAKE_BASE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
set(CMAKE_SWIG_ROOT_OUTDIR ${CMAKE_BINARY_DIR}/bindings)
set(CMAKE_SWIG_OUTDIR ${CMAKE_SWIG_ROOT_OUTDIR})
# Set build flags
option(BUILD_STATIC "Build static Showtime library" OFF)
option(BUILD_SHARED "Build shared Showtime library" ON)
option(BUILD_SHARED_FROM_STATIC_LIBS "Build shared Showtime library from only static libs" ON)
option(BUILD_DRAFTS "Build with experimental draft support" OFF)
option(BUILD_SERVER_LAUNCHER "Build server launcher program" ON)
# Set showtime variables
set(Showtime_COMPILED_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/include")
set(Showtime_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/include")
set(Showtime_ALL_INCLUDE_DIRS ${Showtime_COMPILED_INCLUDE_DIRS} ${Showtime_INCLUDE_DIRS})
set(Showtime_SUBMODULE_DEPENDENCIES_DIR "${CMAKE_SOURCE_DIR}/submodules")
set(Showtime_API_INTERFACE "")
set(Showtime_OBJECT_TARGETS "")
set(Showtime_LIBRARY_TARGETS "")
set(Showtime_APP_TARGETS "")
set(Showtime_INSTALL_TARGETS "")
# Boost properties
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_NO_SYSTEM_PATHS ON)
if(NOT Boost_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif()
if(NOT BUILD_SHARED AND NOT BUILD_STATIC AND NOT BUILD_SHARED_FROM_STATIC_LIBS)
message(FATAL_ERROR "Need to set either BUILD_SHARED or BUILD_STATIC or BUILD_SHARED_FROM_STATIC_LIBS")
endif()
# --------
# Packages
# --------
set(LIBZMQ_TARGET "")
set(CZMQ_TARGET "")
message(STATUS "Finding packages")
# Boost
# --------
set(BOOST_COMPONENTS
log
log_setup
thread
system
context
fiber
date_time
chrono
atomic
regex
unit_test_framework
)
find_package(Boost COMPONENTS ${BOOST_COMPONENTS} CONFIG)
if(NOT Boost_FOUND)
message(STATUS "Searching for Boost using cmake's FindBoost")
find_package(Boost COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
endif()
# swig
# ------------------------------
find_host_package(SWIG REQUIRED)
if(SWIG_FOUND)
cmake_policy(SET CMP0078 NEW)
cmake_policy(SET CMP0086 NEW)
include(UseSWIG)
set(UseSWIG_MODULE_VERSION 2)
endif()
# CZMQ, libZMQ
# ----
find_package(ZeroMQ CONFIG)
if(NOT ZeroMQ_FOUND)
message(STATUS "Searching for libzmq using fallback Findlibzmq.cmake")
find_package(libzmq REQUIRED)
message(STATUS "libZMQ found status: ${libzmq_FOUND}")
endif()
find_package(czmq CONFIG)
if(NOT czmq_FOUND)
message(STATUS "Searching for czmq using fallback Findczmq.cmake")
find_package(czmq REQUIRED)
message(STATUS "CZMQ found status: ${czmq_FOUND}")
endif()
cmake_policy(SET CMP0048 NEW)
find_host_package(Flatbuffers CONFIG REQUIRED)
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
find_host_program(FLATBUFFERS_FLATC_EXECUTABLE flatc)
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
message(FATAL_ERROR "Could not find flatc compiler!")
endif()
endif()
find_package(fmt CONFIG REQUIRED)
set(FLATBUFFFER_OUTPUT_DIR "${Showtime_COMPILED_INCLUDE_DIRS}/showtime/schemas")
set(FLATBUFFER_HEADER_OUTPUT
"${FLATBUFFFER_OUTPUT_DIR}/messaging/stage_beacon_message_generated.h"
"${FLATBUFFFER_OUTPUT_DIR}/messaging/stage_message_generated.h"
"${FLATBUFFFER_OUTPUT_DIR}/messaging/graph_message_generated.h"
"${FLATBUFFFER_OUTPUT_DIR}/messaging/graph_types_generated.h"
)
set(FLATC_ARGS
"-c"
"-o" "${FLATBUFFFER_OUTPUT_DIR}/messaging"
"-I" "${CMAKE_SOURCE_DIR}/schemas/messaging"
"${CMAKE_SOURCE_DIR}/schemas/messaging/stage_message.fbs"
"${CMAKE_SOURCE_DIR}/schemas/messaging/stage_beacon_message.fbs"
"${CMAKE_SOURCE_DIR}/schemas/messaging/graph_message.fbs"
"${CMAKE_SOURCE_DIR}/schemas/messaging/graph_types.fbs"
)
execute_process(COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} ${FLATC_ARGS})
# Set internal linked library lists for our targets
set(SHOWTIME_PRIVATE_LINKED_LIBS
Boost::system
Boost::thread
Boost::date_time
Boost::chrono
Boost::atomic
Boost::regex
Boost::log
Boost::log_setup
Boost::context
Boost::fiber
Boost::boost
Boost::disable_autolinking
${CMAKE_THREAD_LIBS_INIT}
)
set(SHOWTIME_PUBLIC_LINKED_LIBS
fmt::fmt
)
# Boost libraries that MUST be linked shared
set(Showtime_PUBLIC_SHARED_BOOST_LINKED_LIBS
#${Boost_CONTEXT_LIBRARY_DEBUG}
)
# Boost shared DLLs
set(Showtime_SHARED_BOOST_LIBS)
if(WIN32)
# Copy boost dlls
foreach(BOOST_LIB ${Showtime_PUBLIC_SHARED_BOOST_LINKED_LIBS})
get_filename_component(BOOST_LIB_DIR ${BOOST_LIB} DIRECTORY)
get_filename_component(BOOST_LIB_NAME ${BOOST_LIB} NAME_WE)
string(REPLACE "libboost" "boost" BOOST_DLL_NAME ${BOOST_LIB_NAME})
list(APPEND Showtime_SHARED_BOOST_LIBS ${BOOST_LIB_DIR}/${BOOST_DLL_NAME}.dll)
endforeach()
if(${Showtime_SHARED_BOOST_LIBS})
message(STATUS "Additional Boost DLLs that need to be copied: ${Showtime_SHARED_BOOST_LIBS}")
endif()
endif()
# Submodule includes
set(Showtime_HEADER_DEPENDENCIES
$<BUILD_INTERFACE:${Showtime_SUBMODULE_DEPENDENCIES_DIR}/cf>
$<BUILD_INTERFACE:${Showtime_SUBMODULE_DEPENDENCIES_DIR}/uthash/src>
$<BUILD_INTERFACE:${Showtime_SUBMODULE_DEPENDENCIES_DIR}/readerwriterqueue>
$<BUILD_INTERFACE:${Showtime_SUBMODULE_DEPENDENCIES_DIR}/concurrentqueue>
$<BUILD_INTERFACE:${Showtime_SUBMODULE_DEPENDENCIES_DIR}/cxxopts/include>
$<BUILD_INTERFACE:${Showtime_SUBMODULE_DEPENDENCIES_DIR}/delegates/include>
$<BUILD_INTERFACE:${Showtime_SUBMODULE_DEPENDENCIES_DIR}/multifunction>
)
# Copy include headers to build tree
file(MAKE_DIRECTORY ${Showtime_COMPILED_INCLUDE_DIRS})
# TODO: Copy fmt headers but replace with CMake install!
# get_target_property(FMT_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES)
# get_filename_component(FMT_INCLUDE_DIR_REAL "${FMT_INCLUDE_DIR}/fmt" REALPATH)
# get_filename_component(FMT_INCLUDE_DIR_ABS "${FMT_INCLUDE_DIR_REAL}/../" ABSOLUTE)
# message(STATUS "fmt dir is ${FMT_INCLUDE_DIR_ABS}")
# file(COPY ${FMT_INCLUDE_DIR_ABS} DESTINATION ${Showtime_COMPILED_INCLUDE_DIRS} FOLLOW_SYMLINK_CHAIN)
# file(GLOB FMT_HEADERS CONFIGURE_DEPENDS "${FMT_INCLUDE_DIR}/fmt/*.h")
# Copy flatbuffers headers but replace with CMake install!
if(WIN32)
get_target_property(FLATBUFFERS_INCLUDE_DIR flatbuffers::flatbuffers INTERFACE_INCLUDE_DIRECTORIES)
file(GLOB FLATBUFFER_HEADER_SRC CONFIGURE_DEPENDS "${FLATBUFFERS_INCLUDE_DIR}/flatbuffers/*.h")
file(MAKE_DIRECTORY ${Showtime_COMPILED_INCLUDE_DIRS}/flatbuffers)
set(FLATBUFFER_HEADERS "")
foreach(FILE ${FLATBUFFER_HEADER_SRC})
get_filename_component(FILE_N ${FILE} NAME)
set(DEST_F "${Showtime_COMPILED_INCLUDE_DIRS}/flatbuffers/${FILE_N}")
configure_file(${FILE} ${DEST_F} COPYONLY)
list(APPEND FLATBUFFER_HEADERS ${DEST_F})
endforeach()
endif()
# Copy delegate headers
file(COPY ${Showtime_SUBMODULE_DEPENDENCIES_DIR}/multifunction/multicast.hpp DESTINATION ${Showtime_COMPILED_INCLUDE_DIRS}/showtime)
# Set up private targets and vars
set(SHOWTIME_PRIVATE_STATIC_LINKED_LIBS
czmq-static
libzmq-static
)
set(SHOWTIME_PRIVATE_SHARED_LINKED_LIBS
czmq
libzmq
)
set(SHOWTIME_PRIVATE_DEFS
CZMQ_BUILD_DRAFT_API
ZMQ_BUILD_DRAFT_API
)
# Flags to allow for PDB files in release builds
set(SHOWTIME_RELEASE_PDB_COMPILE_DEFINITIONS)
set(SHOWTIME_RELEASE_PDB_LINK_FLAGS)
if(MSVC)
list(APPEND SHOWTIME_RELEASE_PDB_COMPILE_DEFINITIONS $<$<CONFIG:Release>:/Zi>)
list(APPEND SHOWTIME_RELEASE_PDB_LINK_FLAGS $<$<CONFIG:Release>:/INCREMENTAL:NO;/DEBUG;/OPT:REF;/OPT:ICF>)
endif()
# ----------------
# Showtime targets
# ----------------
# Core Library
# ------------
set(CORE_TARGET "${PROJECT_NAME}Core")
set(CORE_TARGET_STATIC "${PROJECT_NAME}CoreStatic")
set(CORE_TARGET_OBJECTS "${CORE_TARGET}Objects")
# Object target includes
set(CORE_INCLUDES
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${Showtime_HEADER_DEPENDENCIES}>
$<BUILD_INTERFACE:${Showtime_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${Showtime_COMPILED_INCLUDE_DIRS}>
)
add_library(${CORE_TARGET_OBJECTS} OBJECT "")
list(APPEND Showtime_OBJECT_TARGETS ${CORE_TARGET_OBJECTS})
if(BUILD_STATIC)
add_library(${CORE_TARGET_STATIC} STATIC "")
list(APPEND Showtime_LIBRARY_TARGETS ${CORE_TARGET_STATIC})
endif()
if(BUILD_SHARED)
add_library(${CORE_TARGET} SHARED "")
list(APPEND Showtime_LIBRARY_TARGETS ${CORE_TARGET})
endif()
include(src/core/CMakeLists.txt)
# Client Library
# --------------
set(CLIENT_TARGET "${PROJECT_NAME}Client")
set(CLIENT_TARGET_STATIC "${PROJECT_NAME}ClientStatic")
set(CLIENT_TARGET_OBJECTS "${CLIENT_TARGET}Objects")
add_library(${CLIENT_TARGET_OBJECTS} OBJECT "")
list(APPEND Showtime_OBJECT_TARGETS ${CLIENT_TARGET_OBJECTS})
if(BUILD_STATIC)
add_library(${CLIENT_TARGET_STATIC} STATIC "")
list(APPEND Showtime_LIBRARY_TARGETS ${CLIENT_TARGET_STATIC})
endif()
if(BUILD_SHARED)
add_library(${CLIENT_TARGET} SHARED "")
list(APPEND Showtime_LIBRARY_TARGETS ${CLIENT_TARGET})
endif()
include(src/client/CMakeLists.txt)
# Server binary
# -------------
set(SERVER_TARGET "${PROJECT_NAME}Server")
set(SERVER_TARGET_STATIC "${PROJECT_NAME}ServerStatic")
set(SERVER_TARGET_OBJECTS ${SERVER_TARGET}Objects)
set(SERVER_LAUNCHER "${PROJECT_NAME}ServerLauncher")
add_library(${SERVER_TARGET_OBJECTS} OBJECT "")
list(APPEND Showtime_OBJECT_TARGETS ${SERVER_TARGET_OBJECTS})
if(BUILD_STATIC)
add_library (${SERVER_TARGET_STATIC} STATIC "")
list(APPEND Showtime_LIBRARY_TARGETS ${SERVER_TARGET_STATIC})
endif()
if(BUILD_SHARED)
add_library (${SERVER_TARGET} SHARED "")
list(APPEND Showtime_LIBRARY_TARGETS ${SERVER_TARGET})
endif()
if(BUILD_SERVER_LAUNCHER)
add_executable (${SERVER_LAUNCHER} "")
list(APPEND Showtime_APP_TARGETS ${SERVER_LAUNCHER})
endif()
include(src/server/CMakeLists.txt)
# Combined binary
# -------------
set(SHARED_FROM_STATIC_TARGET Showtime)
if(BUILD_SHARED_FROM_STATIC_LIBS)
add_library (${SHARED_FROM_STATIC_TARGET} SHARED "")
target_sources(${SHARED_FROM_STATIC_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/dummy.cpp)
set(SHARED_LINK_OPTIONS "")
set(SHARED_LINK_OPTIONS_START "")
set(SHARED_LINK_OPTIONS_END "")
if(WIN32)
# set(SHARED_LINK_OPTIONS
# "/WHOLEARCHIVE:$<TARGET_FILE_NAME:${CORE_TARGET_STATIC}>"
# "/WHOLEARCHIVE:$<TARGET_FILE_NAME:${CLIENT_TARGET_STATIC}>"
# "/WHOLEARCHIVE:$<TARGET_FILE_NAME:${SERVER_TARGET_STATIC}>"
# )
elseif(ANDROID)
# set(SHARED_LINK_OPTIONS_START "-Wl,--whole-archive")
# set(SHARED_LINK_OPTIONS_END "-Wl,--no-whole-archive")
elseif(MACOSX)
# set(SHARED_LINK_OPTIONS "-Wl,-all_load")
endif()
target_link_libraries(${SHARED_FROM_STATIC_TARGET}
PRIVATE
${SHARED_LINK_OPTIONS_START}
${CORE_TARGET_OBJECTS}
${CLIENT_TARGET_OBJECTS}
${SERVER_TARGET_OBJECTS}
${SHOWTIME_PRIVATE_STATIC_LINKED_LIBS}
${SHARED_LINK_OPTIONS_END}
PUBLIC
${SHOWTIME_PUBLIC_LINKED_LIBS}
)
target_include_directories(${SHARED_FROM_STATIC_TARGET} PUBLIC
${CORE_INCLUDES}
)
target_compile_definitions(${SHARED_FROM_STATIC_TARGET} PUBLIC
ZST_EXPORT_CLIENT_API
ZST_EXPORT_CORE_API
ZST_EXPORT_PLUGIN_API
ZST_EXPORT_SERVER_API
PRIVATE
${GLOBAL_PUBLIC_DEFINES}
${SHOWTIME_PRIVATE_DEFS}
CZMQ_STATIC
ZMQ_STATIC
)
target_link_options(${SHARED_FROM_STATIC_TARGET}
PRIVATE
${SHARED_LINK_OPTIONS}
)
add_dependencies(${SHARED_FROM_STATIC_TARGET}
${CORE_TARGET_OBJECTS}
${CLIENT_TARGET_OBJECTS}
${SERVER_TARGET_OBJECTS}
)
list(APPEND Showtime_LIBRARY_TARGETS ${SHARED_FROM_STATIC_TARGET})
# Dev
get_target_property(SHARED_STATIC_LINKED_LIBS ${SHARED_FROM_STATIC_TARGET} LINK_LIBRARIES)
message(STATUS ${SHARED_STATIC_LINKED_LIBS})
endif()
# Web monitor
# -------------
#set(MONITOR_TARGET "${PROJECT_NAME}Monitor")
#include(src/monitor/CMakeLists.txt)
#list(APPEND Showtime_APP_TARGETS ${MONITOR_TARGET})
# ------
# Plugins
# ------
set(PLUGIN_OUTPUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins)
set(Showtime_PLUGIN_TARGETS "")
# Core entity plugin
# -------------------
set(CORE_ENTITIES_TARGET "${PROJECT_NAME}PluginCoreEntities")
add_library(${CORE_ENTITIES_TARGET} MODULE "")
include(src/plugins/core_entities/CMakeLists.txt)
list(APPEND Showtime_PLUGIN_TARGETS ${CORE_ENTITIES_TARGET})
# Container options
# -----------------
option(BUILD_ANDROID_CONTAINER "Build Android libs using Singularity" OFF)
set(ANDROID_CONTAINER_TARGET AndroidContainerBuild)
set(ANDROID_LIB_DIR "${CMAKE_BINARY_DIR}/lib/Android")
set(ANDROID_BIN_DIR "${CMAKE_BINARY_DIR}/bin/Android")
set(ANDROID_OUTPUT_LIB "${ANDROID_LIB_DIR}/lib${SHARED_FROM_STATIC_TARGET}.so")
option(BUILD_WINDOWS_CONTAINER "Build Windows libs using Vagrant" OFF)
set(WINDOWS_CONTAINER_TARGET WindowsContainerBuild)
set(WINDOWS_LIB_DIR "${CMAKE_BINARY_DIR}/lib/Windows")
set(WINDOWS_BIN_DIR "${CMAKE_BINARY_DIR}/bin/Windows")
set(WINDOWS_CONTAINER_OUTPUT_LIB "${WINDOWS_BIN_DIR}/${CLIENT_TARGET}.dll")
option(BUILD_MACOS_CONTAINER "Build MacOS libs using Vagrant" OFF)
set(MACOS_CONTAINER_TARGET MacOSContainerBuild)
set(MACOS_LIB_DIR "${CMAKE_BINARY_DIR}/lib/Darwin")
set(MACOS_BIN_DIR "${CMAKE_BINARY_DIR}/bin/Darwin")
set(MACOS_CONTAINER_OUTPUT_LIB "${MACOS_LIB_DIR}/lib${CLIENT_TARGET}.dylib")
set(CONTAINER_DIR ${CMAKE_BINARY_DIR}/containers)
file(MAKE_DIRECTORY ${CONTAINER_DIR})
# Use Vagrant to create/run our build containers
if(BUILD_ANDROID_CONTAINER OR BUILD_WINDOWS_CONTAINER OR BUILD_MACOS_CONTAINER)
find_program(VAGRANTCOMMAND vagrant)
if(${VAGRANTCOMMAND} EQUAL vagrant-NOTFOUND)
message(FATAL_ERROR "Could not find Vagrant")
endif()
# Install vagrant scp plugin
execute_process(COMMAND ${VAGRANTCOMMAND} plugin list OUTPUT_VARIABLE VAGRANT_PLUGIN_LIST)
string(FIND ${VAGRANT_PLUGIN_LIST} "vagrant-scp" VAGRANT_SCP_PLUGIN_FOUND)
if(${VAGRANT_SCP_PLUGIN_FOUND} LESS 0)
execute_process(COMMAND ${VAGRANTCOMMAND} plugin install vagrant-scp)
endif()
# Install vagrant disksize plugin
execute_process(COMMAND ${VAGRANTCOMMAND} plugin list OUTPUT_VARIABLE VAGRANT_PLUGIN_LIST)
string(FIND ${VAGRANT_PLUGIN_LIST} "vagrant-disksize" VAGRANT_DISK_PLUGIN_FOUND)
if(${VAGRANT_DISK_PLUGIN_FOUND} LESS 0)
execute_process(COMMAND ${VAGRANTCOMMAND} plugin install vagrant-disksize)
endif()
# Set container VM properties
set(CONTAINER_CPU_COUNT 4 CACHE STRING "Number of cpu cores to run build containers with")
set(CONTAINER_MEMORY_AMOUNT 4096 CACHE STRING "Amount of RAM to dedicate to the build containers")
endif()
# Container targets
# -----------------
set(PLATFORM_TARGETS "")
if(BUILD_ANDROID_CONTAINER)
add_custom_target(${ANDROID_CONTAINER_TARGET} ALL DEPENDS ${ANDROID_OUTPUT_LIB})
list(APPEND PLATFORM_TARGETS ${ANDROID_CONTAINER_TARGET})
include(containers/android/CMakeLists.txt)
endif()
if(BUILD_WINDOWS_CONTAINER)
add_custom_target(${WINDOWS_CONTAINER_TARGET} ALL DEPENDS ${WINDOWS_CONTAINER_OUTPUT_LIB})
list(APPEND PLATFORM_TARGETS ${WINDOWS_CONTAINER_TARGET})
include(containers/windows/CMakeLists.txt)
endif()
if(BUILD_MACOS_CONTAINER)
add_custom_target(${MACOS_CONTAINER_TARGET} ALL DEPENDS ${MACOS_CONTAINER_OUTPUT_LIB})
list(APPEND PLATFORM_TARGETS ${MACOS_CONTAINER_TARGET})
include(containers/macos/CMakeLists.txt)
endif()
# Bindings
# -------
include(bindings/CMakeLists.txt)
# Tests
# -----
include( CTest )
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
# Installation
# ------------
set(CMAKE_INSTALL_CMAKEDIR "lib/cmake/showtime")
# Install targets
set(Showtime_INSTALL_TARGETS
${Showtime_OBJECT_TARGETS}
${Showtime_LIBRARY_TARGETS}
${Showtime_APP_TARGETS}
# ${Showtime_PLUGIN_TARGETS}
)
# Set files to copy
install(DIRECTORY ${Showtime_ALL_INCLUDE_DIRS} DESTINATION ${CMAKE_INSTALL_PREFIX})
foreach(lib ${SHOWTIME_PUBLIC_SHARED_LINKED_LIBS})
install(FILES $<TARGET_FILE:${lib}> DESTINATION bin)
endforeach()
if(MACOSX)
# Install framework
install(TARGETS ${Showtime_INSTALL_TARGETS}
EXPORT showtime-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
FRAMEWORK DESTINATION /Library/Frameworks
)
else()
# Install targets
install(TARGETS ${Showtime_INSTALL_TARGETS}
DESTINATION ${CMAKE_INSTALL_PREFIX}
EXPORT showtime-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endif()
# Export targets
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
export(EXPORT showtime-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/showtime-targets.cmake"
NAMESPACE ${SHOWTIME_NAMESPACE}
)
endif()
# Install target exports
install(EXPORT showtime-targets
FILE showtime-targets.cmake
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
NAMESPACE ${SHOWTIME_NAMESPACE}
)
# Set up CMake package
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
showtime-config-version.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file (showtime-config.cmake.in
showtime-config.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
)
# Install package files
install (
FILES
"${CMAKE_CURRENT_BINARY_DIR}/showtime-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/showtime-config-version.cmake"
DESTINATION
"${CMAKE_INSTALL_CMAKEDIR}"
)