-
Notifications
You must be signed in to change notification settings - Fork 788
/
CMakeLists.txt
738 lines (656 loc) · 27.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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(CheckCXXSourceCompiles)
# Set source files
if(WIN32)
file(GLOB_RECURSE ALL_HEADERS
${PROJECT_SOURCE_DIR}/include/**/*.h
${PROJECT_SOURCE_DIR}/include/**/*.hpp
${PROJECT_SOURCE_DIR}/src/cpp/**/*.h
${PROJECT_SOURCE_DIR}/src/cpp/**/*.hpp
)
add_definitions(-DNOMINMAX)
endif(WIN32)
file(GLOB DDSSQLFILTER_SOURCES fastdds/topic/DDSSQLFilter/*.cpp)
set(${PROJECT_NAME}_source_files
${ALL_HEADERS}
${DDSSQLFILTER_SOURCES}
fastdds/log/Log.cpp
fastdds/log/OStreamConsumer.cpp
fastdds/log/StdoutErrConsumer.cpp
fastdds/log/StdoutConsumer.cpp
fastdds/log/FileConsumer.cpp
rtps/common/Time_t.cpp
rtps/resources/ResourceEvent.cpp
rtps/resources/TimedEvent.cpp
rtps/resources/TimedEventImpl.cpp
rtps/writer/LivelinessManager.cpp
rtps/writer/LocatorSelectorSender.cpp
rtps/writer/RTPSWriter.cpp
rtps/writer/StatefulWriter.cpp
rtps/writer/ReaderProxy.cpp
rtps/writer/StatelessWriter.cpp
rtps/writer/ReaderLocator.cpp
rtps/history/CacheChangePool.cpp
rtps/history/History.cpp
rtps/history/WriterHistory.cpp
rtps/history/ReaderHistory.cpp
rtps/history/TopicPayloadPool.cpp
rtps/history/TopicPayloadPoolRegistry.cpp
rtps/DataSharing/DataSharingPayloadPool.cpp
rtps/DataSharing/DataSharingListener.cpp
rtps/DataSharing/DataSharingNotification.cpp
rtps/reader/WriterProxy.cpp
rtps/reader/StatefulReader.cpp
rtps/reader/StatelessReader.cpp
rtps/reader/RTPSReader.cpp
rtps/messages/RTPSMessageCreator.cpp
rtps/messages/RTPSMessageGroup.cpp
rtps/messages/RTPSGapBuilder.cpp
rtps/messages/SendBuffersManager.cpp
rtps/messages/MessageReceiver.cpp
rtps/messages/submessages/AckNackMsg.hpp
rtps/messages/submessages/DataMsg.hpp
rtps/messages/submessages/GapMsg.hpp
rtps/messages/submessages/HeartbeatMsg.hpp
rtps/network/ExternalLocatorsProcessor.cpp
rtps/network/NetworkFactory.cpp
rtps/network/ReceiverResource.cpp
rtps/participant/RTPSParticipant.cpp
rtps/participant/RTPSParticipantImpl.cpp
rtps/RTPSDomain.cpp
fastrtps_deprecated/Domain.cpp
fastrtps_deprecated/participant/Participant.cpp
fastrtps_deprecated/participant/ParticipantImpl.cpp
fastrtps_deprecated/publisher/Publisher.cpp
fastrtps_deprecated/publisher/PublisherImpl.cpp
fastrtps_deprecated/publisher/PublisherHistory.cpp
fastrtps_deprecated/subscriber/Subscriber.cpp
fastrtps_deprecated/subscriber/SubscriberImpl.cpp
fastrtps_deprecated/subscriber/SubscriberHistory.cpp
fastdds/publisher/DataWriter.cpp
fastdds/publisher/DataWriterImpl.cpp
fastdds/publisher/DataWriterHistory.cpp
fastdds/topic/ContentFilteredTopic.cpp
fastdds/topic/ContentFilteredTopicImpl.cpp
fastdds/topic/Topic.cpp
fastdds/topic/TopicImpl.cpp
fastdds/topic/TopicProxyFactory.cpp
fastdds/topic/TypeSupport.cpp
fastdds/topic/qos/TopicQos.cpp
fastdds/publisher/qos/DataWriterQos.cpp
fastdds/subscriber/qos/DataReaderQos.cpp
fastdds/publisher/PublisherImpl.cpp
fastdds/publisher/qos/PublisherQos.cpp
fastdds/publisher/Publisher.cpp
fastdds/subscriber/SubscriberImpl.cpp
fastdds/subscriber/qos/SubscriberQos.cpp
fastdds/subscriber/Subscriber.cpp
fastdds/subscriber/DataReader.cpp
fastdds/subscriber/DataReaderImpl.cpp
fastdds/subscriber/ReadCondition.cpp
fastdds/subscriber/history/DataReaderHistory.cpp
fastdds/domain/DomainParticipantFactory.cpp
fastdds/domain/DomainParticipantImpl.cpp
fastdds/domain/DomainParticipant.cpp
fastdds/domain/qos/DomainParticipantQos.cpp
fastdds/domain/qos/DomainParticipantFactoryQos.cpp
fastdds/builtin/typelookup/common/TypeLookupTypes.cpp
fastdds/builtin/common/RPCHeadersImpl.cpp
fastdds/builtin/typelookup/TypeLookupManager.cpp
fastdds/builtin/typelookup/TypeLookupRequestListener.cpp
fastdds/builtin/typelookup/TypeLookupReplyListener.cpp
rtps/transport/ChannelResource.cpp
rtps/transport/UDPChannelResource.cpp
rtps/transport/TCPChannelResource.cpp
rtps/transport/TCPChannelResourceBasic.cpp
rtps/transport/TCPAcceptor.cpp
rtps/transport/TCPAcceptorBasic.cpp
rtps/transport/UDPv4Transport.cpp
rtps/transport/TCPTransportInterface.cpp
rtps/transport/UDPTransportInterface.cpp
rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp
rtps/transport/TCPv4Transport.cpp
rtps/transport/UDPv6Transport.cpp
rtps/transport/TCPv6Transport.cpp
rtps/transport/test_UDPv4Transport.cpp
rtps/transport/tcp/TCPControlMessage.cpp
rtps/transport/tcp/RTCPMessageManager.cpp
rtps/transport/ChainingTransport.cpp
dynamic-types/AnnotationDescriptor.cpp
dynamic-types/AnnotationParameterValue.cpp
dynamic-types/DynamicData.cpp
dynamic-types/DynamicDataFactory.cpp
dynamic-types/DynamicType.cpp
dynamic-types/DynamicPubSubType.cpp
dynamic-types/DynamicTypePtr.cpp
dynamic-types/DynamicDataPtr.cpp
dynamic-types/DynamicTypeBuilder.cpp
dynamic-types/DynamicTypeBuilderPtr.cpp
dynamic-types/DynamicTypeBuilderFactory.cpp
dynamic-types/DynamicTypeMember.cpp
dynamic-types/MemberDescriptor.cpp
dynamic-types/TypeDescriptor.cpp
dynamic-types/TypeIdentifier.cpp
dynamic-types/TypeIdentifierTypes.cpp
dynamic-types/TypeObject.cpp
dynamic-types/TypeObjectHashId.cpp
dynamic-types/TypeObjectFactory.cpp
dynamic-types/TypeNamesGenerator.cpp
dynamic-types/TypesBase.cpp
dynamic-types/BuiltinAnnotationsTypeObject.cpp
dynamic-types/DynamicDataHelper.cpp
fastrtps_deprecated/attributes/TopicAttributes.cpp
fastdds/core/Entity.cpp
fastdds/core/condition/Condition.cpp
fastdds/core/condition/ConditionNotifier.cpp
fastdds/core/condition/GuardCondition.cpp
fastdds/core/condition/StatusCondition.cpp
fastdds/core/condition/StatusConditionImpl.cpp
fastdds/core/condition/WaitSet.cpp
fastdds/core/condition/WaitSetImpl.cpp
fastdds/core/policy/ParameterList.cpp
fastdds/core/policy/QosPolicyUtils.cpp
fastdds/publisher/qos/WriterQos.cpp
fastdds/subscriber/qos/ReaderQos.cpp
fastdds/utils/QosConverters.cpp
rtps/builtin/BuiltinProtocols.cpp
rtps/builtin/discovery/participant/DirectMessageSender.cpp
rtps/builtin/discovery/participant/PDP.cpp
rtps/builtin/discovery/participant/ServerAttributes.cpp
rtps/builtin/discovery/participant/PDPSimple.cpp
rtps/builtin/discovery/participant/PDPListener.cpp
rtps/builtin/discovery/endpoint/EDP.cpp
rtps/builtin/discovery/endpoint/EDPSimple.cpp
rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp
rtps/builtin/discovery/endpoint/EDPStatic.cpp
rtps/builtin/liveliness/WLP.cpp
rtps/builtin/liveliness/WLPListener.cpp
rtps/builtin/data/ParticipantProxyData.cpp
rtps/builtin/data/WriterProxyData.cpp
rtps/builtin/data/ReaderProxyData.cpp
rtps/flowcontrol/ThroughputControllerDescriptor.cpp
rtps/flowcontrol/FlowControllerConsts.cpp
rtps/flowcontrol/FlowControllerFactory.cpp
rtps/exceptions/Exception.cpp
rtps/attributes/PropertyPolicy.cpp
rtps/common/Token.cpp
rtps/xmlparser/XMLParserCommon.cpp
rtps/xmlparser/XMLElementParser.cpp
rtps/xmlparser/XMLDynamicParser.cpp
rtps/xmlparser/XMLEndpointParser.cpp
rtps/xmlparser/XMLParser.cpp
rtps/xmlparser/XMLProfileManager.cpp
rtps/writer/PersistentWriter.cpp
rtps/writer/StatelessPersistentWriter.cpp
rtps/writer/StatefulPersistentWriter.cpp
rtps/reader/StatelessPersistentReader.cpp
rtps/reader/StatefulPersistentReader.cpp
rtps/persistence/PersistenceFactory.cpp
rtps/builtin/discovery/database/backup/SharedBackupFunctions.cpp
rtps/builtin/discovery/endpoint/EDPClient.cpp
rtps/builtin/discovery/endpoint/EDPServer.cpp
rtps/builtin/discovery/endpoint/EDPServerListeners.cpp
rtps/builtin/discovery/database/DiscoveryDataBase.cpp
rtps/builtin/discovery/database/DiscoveryParticipantInfo.cpp
rtps/builtin/discovery/database/DiscoveryParticipantsAckStatus.cpp
rtps/builtin/discovery/database/DiscoverySharedInfo.cpp
rtps/builtin/discovery/participant/PDPClient.cpp
rtps/builtin/discovery/participant/PDPServer.cpp
rtps/builtin/discovery/participant/PDPServerListener.cpp
rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp
rtps/builtin/discovery/participant/timedevent/DServerEvent.cpp
utils/IPFinder.cpp
utils/md5.cpp
utils/StringMatching.cpp
utils/IPLocator.cpp
utils/System.cpp
utils/SystemInfo.cpp
utils/TimedConditionVariable.cpp
utils/string_convert.cpp
dds/core/types.cpp
dds/core/Exception.cpp
dds/domain/DomainParticipant.cpp
dds/pub/Publisher.cpp
dds/pub/AnyDataWriter.cpp
dds/pub/DataWriter.cpp
dds/sub/Subscriber.cpp
dds/sub/DataReader.cpp
dds/topic/Topic.cpp
statistics/fastdds/domain/DomainParticipant.cpp
statistics/fastdds/publisher/qos/DataWriterQos.cpp
statistics/fastdds/subscriber/qos/DataReaderQos.cpp
)
# Statistics support
if (FASTDDS_STATISTICS)
set(statistics_sources
statistics/fastdds/domain/DomainParticipantImpl.cpp
statistics/fastdds/domain/DomainParticipantStatisticsListener.cpp
statistics/rtps/StatisticsBase.cpp
statistics/rtps/reader/StatisticsReaderImpl.cpp
statistics/rtps/writer/StatisticsWriterImpl.cpp
statistics/types/typesPubSubTypes.cxx
statistics/types/types.cxx
)
list(APPEND ${PROJECT_NAME}_source_files
${statistics_sources}
)
endif()
# SHM Transport
if(IS_THIRDPARTY_BOOST_OK)
list(APPEND ${PROJECT_NAME}_source_files
rtps/transport/shared_mem/test_SharedMemTransport.cpp
rtps/transport/shared_mem/SharedMemTransport.cpp
)
endif()
# TLS Support
if(TLS_FOUND)
list(APPEND ${PROJECT_NAME}_source_files
rtps/transport/TCPChannelResourceSecure.cpp
rtps/transport/TCPAcceptorSecure.cpp
)
endif()
# Security sources
set(${PROJECT_NAME}_security_source_files
rtps/security/exceptions/SecurityException.cpp
rtps/security/common/SharedSecretHandle.cpp
rtps/security/logging/Logging.cpp
rtps/security/SecurityManager.cpp
rtps/security/SecurityPluginFactory.cpp
rtps/builtin/discovery/participant/DS/PDPSecurityInitiatorListener.cpp
security/authentication/PKIDH.cpp
security/accesscontrol/Permissions.cpp
security/accesscontrol/DistinguishedName.cpp
security/cryptography/AESGCMGMAC.cpp
security/cryptography/AESGCMGMAC_KeyExchange.cpp
security/cryptography/AESGCMGMAC_KeyFactory.cpp
security/cryptography/AESGCMGMAC_Transform.cpp
security/cryptography/AESGCMGMAC_Types.cpp
security/authentication/PKIIdentityHandle.cpp
security/authentication/PKIHandshakeHandle.cpp
security/accesscontrol/AccessPermissionsHandle.cpp
security/accesscontrol/CommonParser.cpp
security/accesscontrol/GovernanceParser.cpp
security/accesscontrol/PermissionsParser.cpp
security/logging/LogTopic.cpp
security/artifact_providers/FileProvider.cpp
security/artifact_providers/Pkcs11Provider.cpp
)
if(SECURITY)
list(APPEND ${PROJECT_NAME}_source_files
${${PROJECT_NAME}_security_source_files}
)
set(HAVE_SECURITY 1)
else()
set(HAVE_SECURITY 0)
endif()
if(WIN32 AND (MSVC OR MSVC_IDE))
list(APPEND ${PROJECT_NAME}_source_files
${PROJECT_SOURCE_DIR}/src/cpp/fastrtps.rc
)
endif()
#SQLITE3 persistence service sources
set(${PROJECT_NAME}_sqlite3_source_files
rtps/persistence/SQLite3PersistenceService.cpp
rtps/persistence/sqlite3.c
)
if(SQLITE3_SUPPORT)
list(APPEND ${PROJECT_NAME}_source_files
${${PROJECT_NAME}_sqlite3_source_files}
)
set(HAVE_SQLITE3 1)
# sqlite.c requires a C compiler
enable_language(C)
else()
set(HAVE_SQLITE3 0)
endif()
# External sources
if(TINYXML2_SOURCE_DIR)
set(TINYXML2_SOURCE_DIR_ ${TINYXML2_SOURCE_DIR})
list(APPEND ${PROJECT_NAME}_source_files
${TINYXML2_SOURCE_DIR_}/tinyxml2.cpp
)
endif()
if(ANDROID)
if((ANDROID_PLATFORM LESS_EQUAL 23) OR (ANDROID_NATIVE_API_LEVEL LESS_EQUAL 23))
list(APPEND ${PROJECT_NAME}_source_files
${ANDROID_IFADDRS_SOURCE_DIR}/ifaddrs.c
)
endif()
endif()
# Option to enable strict real-time. In this case, several API functions have a real-time behaviour.
# * Publisher::write() - Uses ReliabilityQosPolicy.max_blocking_time
# * Subscriber::takeNextData() - Uses ReliabilityQosPolicy.max_blocking_time
# * Subscriber::readNextData() - Uses ReliabilityQosPolicy.max_blocking_time
option(STRICT_REALTIME "Enable a strict real-time behavour." OFF)
if(STRICT_REALTIME)
set(HAVE_STRICT_REALTIME 1)
else()
set(HAVE_STRICT_REALTIME 0)
endif()
if(NOT ANDROID)
find_package(Threads REQUIRED)
endif()
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
endif()
# Find out if libatomic link is required in this platform
find_package(Atomic MODULE)
# Check if the shared_mutex provided by the platform STL library
# prioritizes writes
# try_run cannot manage targets yet
get_target_property(CMAKE_ATOMIC_LIB eProsima_atomic INTERFACE_LINK_LIBRARIES)
if(NOT CMAKE_ATOMIC_LIB)
set(CMAKE_ATOMIC_LIB)
endif()
try_run(SM_RUN_RESULT SM_COMPILE_RESULT
"${PROJECT_BINARY_DIR}/shmtest"
"${PROJECT_SOURCE_DIR}/cmake/modules/check_shared_mutex_priority.cpp"
LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_ATOMIC_LIB}
RUN_OUTPUT_VARIABLE SM_RUN_OUTPUT)
if(SM_COMPILE_RESULT AND NOT SM_RUN_RESULT)
string(STRIP ${SM_RUN_OUTPUT} SM_RUN_OUTPUT)
message(STATUS "Framework's shared_mutex is ${SM_RUN_OUTPUT}")
endif()
if(SM_RUN_OUTPUT STREQUAL "PTHREAD_RWLOCK_PREFER_READER_NP")
set(USER_CAN_CHOOSE_SHARED_MEMORY_THIRDPARTY ON)
else()
message(STATUS "Forcing third party shared_mutex")
set(USE_THIRDPARTY_SHARED_MUTEX ON)
endif()
cmake_dependent_option(
USE_THIRDPARTY_SHARED_MUTEX [=[
Forces the use of a Boost-based shared_mutex implementation
instead of the framework one. Useful to cope with issues on
framework implementations like misguided sanitizer reports.
This implementation will be used by default on frameworks
lacking the shared_mutex feature like those not fulfilling
C++17.
]=] OFF
"USER_CAN_CHOOSE_SHARED_MEMORY_THIRDPARTY"
ON)
unset(USER_CAN_CHOOSE_SHARED_MEMORY_THIRDPARTY)
unset(SM_RUN_RESULT)
unset(SM_COMPILE_RESULT)
unset(SM_RUN_OUTPUT)
unset(CMAKE_ATOMIC_LIB)
# Generate the proper configure file
configure_file(${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/config.h.in
${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/config.h)
#Create library
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_source_files})
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
option(INTERNAL_DEBUG "Activate developer debug messages" OFF)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
${PROJECT_NAME_UPPER}_SOURCE
BOOST_ASIO_STANDALONE
ASIO_STANDALONE
ASIO_DISABLE_VISIBILITY
SQLITE_WIN32_GETVERSIONEX=0
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
$<$<BOOL:${INTERNAL_DEBUG}>:__INTERNALDEBUG> # Internal debug activated.
$<$<AND:$<BOOL:${WIN32}>,$<STREQUAL:"${CMAKE_SYSTEM_NAME}","WindowsStore">>:_WIN32_WINNT=0x0603>
$<$<AND:$<BOOL:${WIN32}>,$<NOT:$<STREQUAL:"${CMAKE_SYSTEM_NAME}","WindowsStore">>>:_WIN32_WINNT=0x0601>
$<$<AND:$<BOOL:${WIN32}>,$<STREQUAL:"${CMAKE_SYSTEM_NAME}","WindowsStore">>:SQLITE_OS_WINRT>
$<$<AND:$<BOOL:${ANDROID}>,$<NOT:$<BOOL:${HAVE_CXX14}>>,$<NOT:$<BOOL:${HAVE_CXX1Y}>>>:ASIO_DISABLE_STD_STRING_VIEW>
$<$<BOOL:${WIN32}>:_ENABLE_ATOMIC_ALIGNMENT_FIX>
$<$<NOT:$<BOOL:${IS_THIRDPARTY_BOOST_SUPPORTED}>>:FASTDDS_SHM_TRANSPORT_DISABLED> # Do not compile SHM Transport
$<$<BOOL:${SHM_TRANSPORT_DEFAULT}>:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport
$<$<BOOL:${STDOUTERR_LOG_CONSUMER}>:STDOUTERR_LOG_CONSUMER> # Enable StdoutErrConsumer as default LogConsumer
INTERFACE
$<$<BOOL:${WIN32}>:${PROJECT_NAME_UPPER}_NO_LIB>
PUBLIC
$<$<STREQUAL:$<TARGET_PROPERTY:${PROJECT_NAME},TYPE>,SHARED_LIBRARY>:${PROJECT_NAME_UPPER}_DYN_LINK>
)
# Define public headers
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/cpp>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
PRIVATE
${Asio_INCLUDE_DIR}
$<$<BOOL:${TINYXML2_INCLUDE_DIR}>:${TINYXML2_INCLUDE_DIR}>
$<$<BOOL:${ANDROID}>:${ANDROID_IFADDRS_INCLUDE_DIR}>
${THIRDPARTY_BOOST_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/thirdparty/taocpp-pegtl
)
# No need to expose linked libs when target is a shared library on MSVC.
if(BUILD_SHARED_LIBS AND MSVC)
set(PRIVACY "PRIVATE")
else()
set(PRIVACY "PUBLIC")
endif()
# Link library to external libraries.
target_link_libraries(${PROJECT_NAME} ${PRIVACY} fastcdr foonathan_memory
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}
${TINYXML2_LIBRARY}
$<$<BOOL:${LINK_SSL}>:OpenSSL::SSL$<SEMICOLON>OpenSSL::Crypto$<$<BOOL:${WIN32}>:$<SEMICOLON>crypt32.lib>>
$<$<BOOL:${WIN32}>:iphlpapi$<SEMICOLON>Shlwapi>
${THIRDPARTY_BOOST_LINK_LIBS}
PRIVATE eProsima_atomic
)
if(MSVC OR MSVC_IDE)
# On installed binaries use manifest to specify dependencies
if(INSTALLER_PLATFORM AND OPENSSL_FOUND)
# Get Fast-DDS version suitable manifest format
set(FASTDDS_CANONICAL_VERSION ${fastrtps_VERSION})
if( NOT FASTDDS_CANONICAL_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
message(FATAL_ERROR "Fast-DDS version number ${fastrtps_VERSION} must include major, minor and patch.")
endif()
if( NOT fastrtps_VERSION_TWEAK)
set(FASTDDS_CANONICAL_VERSION "${FASTDDS_CANONICAL_VERSION}.0")
endif()
# Get OpenSSL version suitable manifest format
execute_process( COMMAND PowerShell -NoLogo -Command "&{ param([string]$original)
if ($original -notmatch '\\d+$')
{ $res = $original.Substring(0,$original.length-1) + '.' +
([int]$original[$original.length-1]-[int][char]'a'+1); }
else { while(($original -split '\\.').count -le 3)
{ $original += '.0'; } $res = $original; } $res }" -original ${OPENSSL_VERSION}
OUTPUT_VARIABLE OPENSSL_CANONICAL_VERSION
)
string(STRIP ${OPENSSL_CANONICAL_VERSION} OPENSSL_CANONICAL_VERSION)
# replace the values in the manifest template
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/packaging/windows/fastrtps.manifest.in"
"${PROJECT_BINARY_DIR}/fastrtps.manifest"
@ONLY
)
file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/fastrtps.manifest" MANIFEST_FILE_PATH)
target_link_options(${PROJECT_NAME} PRIVATE "/MANIFEST:EMBED" "/MANIFESTINPUT:${MANIFEST_FILE_PATH}")
unset(WINDOWS_SOURCE_DIR)
unset(FASTDDS_CANONICAL_VERSION)
unset(OPENSSL_CANONICAL_VERSION)
unset(MANIFEST_FILE_PATH)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES
RELEASE_POSTFIX -${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
RELWITHDEBINFO_POSTFIX -${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
DEBUG_POSTFIX d-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
get_target_property(TARGET_TYPE ${PROJECT_NAME} TYPE)
if(TARGET_TYPE STREQUAL "SHARED_LIBRARY")
# Export symbols in DLL library
set_target_properties(${PROJECT_NAME} PROPERTIES
PDB_NAME_DEBUG ${PROJECT_NAME}d-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/symbols"
)
else()
# Rename the library to have a "lib" before.
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME lib${PROJECT_NAME}
COMPILE_PDB_NAME_DEBUG lib${PROJECT_NAME}d-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/symbols"
)
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
set_target_properties(${PROJECT_NAME} PROPERTIES VS_WINRT_COMPONENT "true")
endif()
elseif(BUILD_SHARED_LIBS)
set(VERSION_SCRIPT_SUPPORT_FLAGS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libfastrtps.version)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${VERSION_SCRIPT_SUPPORT_FLAGS})
CHECK_CXX_SOURCE_COMPILES("int main(int, char**){return 0;}" HAS_VERSION_SCRIPT_SUPPORT)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
unset(OLD_CMAKE_REQUIRED_FLAGS)
if(HAS_VERSION_SCRIPT_SUPPORT)
message(STATUS "Using linker version script to select exported symbols")
target_link_options(${PROJECT_NAME} PRIVATE ${VERSION_SCRIPT_SUPPORT_FLAGS})
endif()
endif()
###############################################################################
# Packaging
###############################################################################
# Install public headers
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}
DESTINATION ${INCLUDE_INSTALL_DIR}
COMPONENT headers
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
PATTERN "*.ipp"
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/fastdds
DESTINATION ${INCLUDE_INSTALL_DIR}
COMPONENT headers
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
PATTERN "*.ipp"
)
# Install config.h header
install(FILES ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/config.h
DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}
COMPONENT headers
)
# Install public statistics idls
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/fastdds/statistics
DESTINATION ${INCLUDE_INSTALL_DIR}/fastdds
FILES_MATCHING
PATTERN "*.idl"
)
# Install libraries
install(TARGETS ${PROJECT_NAME} eProsima_atomic
EXPORT ${PROJECT_NAME}-targets
COMPONENT libraries
RUNTIME DESTINATION "${BIN_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION}"
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION}"
)
# Generate different target names depending on linking
get_target_property(TARGET_TYPE ${PROJECT_NAME} TYPE)
if(TARGET_TYPE STREQUAL "SHARED_LIBRARY")
set(FASTDDS_LINKING shared)
else()
set(FASTDDS_LINKING static)
endif()
if(INSTALLER_PLATFORM)
set(INSTALL_DESTINATION_PATH ${DATA_INSTALL_DIR}/${PROJECT_NAME}-${INSTALLER_PLATFORM}/cmake)
else()
set(INSTALL_DESTINATION_PATH ${DATA_INSTALL_DIR}/${PROJECT_NAME}/cmake${MSVCARCH_DIR_EXTENSION_EXT})
endif()
install(EXPORT ${PROJECT_NAME}-targets
DESTINATION ${INSTALL_DESTINATION_PATH}
FILE ${PROJECT_NAME}-${FASTDDS_LINKING}-targets.cmake
COMPONENT cmake
)
if(MSVC OR MSVC_IDE)
# first try dll symbols
get_target_property(PDB_FILE ${PROJECT_NAME} PDB_NAME_DEBUG)
if(PDB_FILE)
get_target_property(PDB_DIR ${PROJECT_NAME} PDB_OUTPUT_DIRECTORY_DEBUG)
set(PDB_FILE "${PDB_DIR}/${PDB_FILE}.pdb")
else()
# fallback to static lib symbols
get_target_property(PDB_FILE ${PROJECT_NAME} COMPILE_PDB_NAME_DEBUG)
if(PDB_FILE)
get_target_property(PDB_DIR ${PROJECT_NAME} COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG)
set(PDB_FILE "${PDB_DIR}/${PDB_FILE}.pdb")
endif()
endif()
# install symbols if any
if(PDB_FILE)
install(FILES ${PDB_FILE}
DESTINATION ${LIB_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION}
COMPONENT symbols
CONFIGURATIONS Debug
)
endif()
endif()
###############################################################################
# Create CMake package config file
###############################################################################
include(CMakePackageConfigHelpers)
if(BUILD_SHARED_LIBS)
set(FASTRTPS_PACKAGE_OPT_BIN_DIR_CONDITION "if(MSVC OR MSVC_IDE)")
else()
set(FASTRTPS_PACKAGE_OPT_BIN_DIR_CONDITION "if(0)")
endif()
# include the option parser targets
set(INCLUDE_FASTDDS_TARGETS "include(\${CMAKE_CURRENT_LIST_DIR}/optionparser-targets.cmake)")
if(COMPILE_TOOLS)
# include the fast-discovery-server targets (not for linking but to hint binaries location and other target properties)
set(INCLUDE_FASTDDS_TARGETS "${INCLUDE_FASTDDS_TARGETS}\ninclude(\${CMAKE_CURRENT_LIST_DIR}/fast-discovery-server-targets.cmake)")
endif()
# Add fastrtps dependencies in its CMake config file.
if(LINK_SSL)
if(INSTALLER_PLATFORM)
# OpenSSL dependency is only propagated on static linking
# We must use the deployed OpenSSL binaries to prevent compatibility issues
set(FASTRTPS_INSTALLER_DEPS_ANCILLARY "\
function(find_fastdds_deployed_openssl)\n\
if(OPENSSL_FOUND AND NOT(OPENSSL_VERSION STREQUAL \"${OPENSSL_VERSION}\") )\n\
message(WARNING \"OpenSSL already loaded. Version \${OPENSSL_VERSION} differs from version ${OPENSSL_VERSION}, used in Fast-DDS binaries building, ABI issues may arise\")\n\
endif()\n\
set(OPENSSL_USE_STATIC_LIBS TRUE)\n\
set(OPENSSL_ROOT_DIR \"\${PACKAGE_PREFIX_DIR}/lib/${INSTALLER_PLATFORM}\")\n\
find_package(OpenSSL REQUIRED)\n\
endfunction()"
)
set(FASTRTPS_INSTALLER_OPT_DEPS "\
if (\${type} STREQUAL \"static\")\n\
find_fastdds_deployed_openssl()\n\
endif()")
elseif(WIN32)
# windows from sources only requires OpenSSL on static libraries
set(FASTRTPS_PACKAGE_WIN32_OPT_DEPS "find_package(OpenSSL REQUIRED)")
else()
# linux from sources requires OpenSSL always
set(FASTRTPS_PACKAGE_UNIX_OPT_DEPS "find_package(OpenSSL REQUIRED)")
endif()
endif()
configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/packaging/Config.cmake.in
${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${INSTALL_DESTINATION_PATH}
PATH_VARS BIN_INSTALL_DIR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR
)
write_basic_package_version_file(${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES ${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config.cmake
${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config-version.cmake
DESTINATION ${INSTALL_DESTINATION_PATH}
COMPONENT cmake
)