-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathFindRTIConnextDDS.cmake
2662 lines (2398 loc) · 87.5 KB
/
FindRTIConnextDDS.cmake
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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#.rst:
# (c) 2017 Copyright, Real-Time Innovations, Inc. All rights reserved.
#
# RTI grants Licensee a license to use, modify, compile, and create derivative
# works of the software solely for use with RTI Connext DDS. Licensee may
# redistribute copies of the software provided that all such copies are
# subject to this license. The software is provided "as is", with no warranty
# of any type, including any warranty for fitness for any purpose. RTI is
# under no obligation to maintain or support the software. RTI shall not be
# liable for any incidental or consequential damages arising out of the use or
# inability to use the software.
#
# FindRTIConnextDDS
# -----------------
#
# Find RTI Connext libraries.
#
# Components
# ^^^^^^^^^^
# This module sets variables for the following components that are part of RTI
# Connext:
# - core (default, always provided)
# - test
# - test_helpers
# - distributed_logger
# - messaging_api
# - routing_service
# - security_plugins
# - security_plugins_wolfssl
# - monitoring_libraries
# - nddstls
# - transport_tcp
# - transport_tls
# - transport_wan
# - recording_service
# - cloud_discovery_service
# - persistence_service
# - web_integration_service
# - low_bandwidth_plugins
# - rtizrtps
#
# Core is always selected, because the rest of components depend on it.
# However, the rest of components must be explicitly selected in the
# find_package invocation for this module to set variables for the different
# libraries associated with them.
#
# Also, the version consistency across all the requested components can be
# checked. If the version between the components missmatch,
# `RTIConnextDDS_FOUND` will be set to `FALSE`. This feature can be enabled
# setting `ENABLE_VERSION_CONSISTENCY_CHECK` to `TRUE`.
#
# Imported Targets
# ^^^^^^^^^^^^^^^^
# This module defines the following `IMPORTED` targets:
#
# - ``RTIConnextDDS::core``
# The base nddscore library.
# - ``RTIConnextDDS::c_api``
# The nddsc library if found (nddscore will be linked as part of this target).
# - ``RTIConnextDDS::cpp_api``
# The nddscpp library if found (nddscore and nddsc will be linked as part of
# this target).
# - ``RTIConnextDDS::cpp2_api``
# The nddscpp2 library if found (nddscore and nddsc will be linked as part
# of this target).
# - ``RTIConnextDDS::metp``
# The METP library if found (nddsmetp).
# - ``RTIConnextDDS::rtixml2``
# The RTI XML2 library if found (rtixml2).
# - ``RTIConnextDDS::apputils_c``.
# The APP Utils C library (rtiapputils).
# - ``RTIConnextDDS::rtisqlite``.
# The RTI SQLite library (rtisqlite).
# - ``RTIConnextDDS::test``.
# The RTI Test Framework library (rtitest).
# - ``RTIConnextDDS::test_helpers``.
# The RTI Test Framework helpers libraries (includes nddsctesthelpers,
# rtitest, nddsc and nddscore)
# - ``RTIConnextDDS::distributed_logger_c``
# The C API library for Distributed Logger if found (includes rtidlc,
# nddscore, and nddsc).
# - ``RTIConnextDDS::distributed_logger_cpp``
# The CPP API library for Distributed Logger if found (includes rtidlcpp,
# rtidlc, nddscore, nddsc and nddscpp).
# - ``RTIConnextDDS::distributed_logger_cpp2``
# The CPP2 API library for Distributed Logger if found (includes rtidlcpp2,
# rtidlc, nddscore, nddsc and nddscpp2).
# - ``RTIConnextDDS::messaging_c_api``
# The Request Reply C API library if found (rticonnextmsgc).
# - ``RTIConnextDDS::messaging_cpp_api``
# The Request Reply CPP API library if found (rticonnextmsgcpp).
# - ``RTIConnextDDS::messaging_cpp2_api``
# The Request Reply CPP2 API library if found (rticonnextmsgcpp2).
# - ``RTIConnextDDS::security_plugins``
# The Security Plugins libraries if found (nddssecurity).
# - ``RTIConnextDDS::monitoring``
# The Monitoring library if found.
# - ``RTIConnextDDS::nddstls``
# The TLS library if found (nddstls).
# - ``RTIConnextDDS::transport_tcp``
# The Transport TCP library if found (nddstransporttcp).
# - ``RTIConnextDDS::transport_tls``
# The Transport TLS library if found (nddstransporttls).
# - ``RTIConnextDDS::transport_wan``
# The Transport WAN library if found (nddstransportwan).
# - ``RTIConnextDDS::low_bandwidth_discovery_static``
# The Discovery Static library for Low Bandwidth Plugins if found
# (nddsdiscoverystatic).
# - ``RTIConnextDDS::low_bandwidth_edisc``
# The edisc library for Low Bandwidth Plugins if found (rtilbedisc).
# - ``RTIConnextDDS::low_bandwidth_pdisc``
# The pdisc library for Low Bandwidth Plugins if found (rtilbpdisc).
# - ``RTIConnextDDS::low_bandwidth_rtps``
# The rtps library for Low Bandwidth Plugins if found (rtilbrtps).
# - ``RTIConnextDDS::low_bandwidth_sm``
# The sm library for Low Bandwidth Plugins if found (rtilbsm).
# - ``RTIConnextDDS::low_bandwidth_st``
# The st library for Low Bandwidth Plugins if found (rtilbst).
# - ``RTIConnextDDS::rtizrtps``
# The rtizrtps library if found (rtizrtps).
# - ``RTIConnextDDS::routing_service_infrastructure``
# The infrastructure library for Routing Service if found.
# - ``RTIConnextDDS::routing_service_c``
# The C API library for Routing Service if found (includes rtiroutingservice,
# rtirsinfrastructure, rtixml2 and rticonnextmsgc; also nddsmetp and
# rticonnextmsgc if found).
# - ``RTIConnextDDS::routing_service``
# The same as RTIConnextDDS::routing_service_c. Maintained for backward
# compatibility.
# - ``RTIConnextDDS::routing_service_cpp``
# The same as RTIConnextDDS::routing_service_c but adding the CPP libraries.
# - ``RTIConnextDDS::routing_service_cpp2``
# The same as RTIConnextDDS::routing_service_c but adding the CPP2 libraries.
# - ``RTIConnextDDS::assign_transformation``
# The assign transformation library if found (includes rtirsassigntransf and
# rtiroutingservice).
# - ``RTIConnextDDS::recording_service``
# The Recording Service library if found (includes rtirecordingservice,
# rtiroutingservice, rtirsinfrastructure, nddscpp2, rtidlc, nddsmetp,
# rticonnextmsgc and rtixml2).
# - ``RTIConnextDDS::cloud_discovery_service_c``
# The Cloud Discovery Service library if found (includes
# rticlouddiscoveryservice, rtiroutingservice, rtirsinfrastructure, nddscpp2,
# rtidlc, nddsmetp, rticonnextmsgc and rtixml2).
# - ``RTIConnextDDS::cloud_discovery_service_cpp``
# The same as RTIConnextDDS::cloud_discovery_service_c but adding the CPP
# libraries.
# - ``RTIConnextDDS::persistence_service_c``
# The C API for Persistence Service if found (includes rtipersistenceservice,
# nddsc, nddscore, rtisqlite, also rtidlc if found).
# - ``RTIConnextDDS::web_integration_service_cpp2``
# The CPP2 API for Web Integration Service if found (rtiwebintegrationservice,
# nddscore, nddsc, nddscpp, nddscpp2, rtiapputilsc, rtisqlite if found).
# Result Variables
# ^^^^^^^^^^^^^^^^
# This module will set the following variables in your project:
#
# - ``CONNEXTDDS_COMPILE_DEFINITIONS``
# RTI Connext Compiler definitions as a list.
# - ``CONNEXTDDS_DEFINITIONS``
# RTI Connext Compiler definitions as a string (deprecated).
# - ``CONNEXTDDS_EXTERNAL_LIBS``
# RTI Connext external dependencies.
# - ``CONNEXTDDS_INCLUDE_DIRS``
# RTI Connext include directories.
# - ``CONNEXTDDS_DLL_EXPORT_MACRO``
# Macros to compile against RTI Connext shared libraries on Windows.
# - ``RTICODEGEN_DIR``
# Path to the directory where RTI Codegen is placed.
# - ``RTICODEGEN``
# Path to the RTI Codegen executable.
# - ``RTICODEGEN_VERSION``
# RTI Codegen version.
#
# This module will set the following variables for all the different libraries
# that are part of the components selected at configuration time.
#
# - ``<LIBRARY_NAME>_LIBRARIES_RELEASE_STATIC``
# Release static libraries for <LIBRARY_NAME>.
# (e.g., ``CONNEXTDDS_C_API_LIBRARIES_RELEASE_STATIC``).
# - ``<LIBRARY_NAME>_LIBRARIES_RELEASE_SHARED``
# Release shared libraries for <LIBRARY_NAME>.
# (e.g., ``CONNEXTDDS_C_API_LIBRARIES_RELEASE_SHARED``).
# - ``<LIBRARY_NAME>_LIBRARIES_DEBUG_STATIC``
# Debug static libraries for <LIBRARY_NAME>.
# (e.g., ``CONNEXTDDS_C_API_LIBRARIES_DEBUG_STATIC``).
# - ``<LIBRARY_NAME>_LIBRARIES_DEBUG_SHARED``
# Debug shared libraries for <LIBRARY_NAME>.
# (e.g., ``CONNEXTDDS_C_API_LIBRARIES_DEBUG_SHARED``).
# - ``<LIBRARY_NAME>_LIBRARIES``
# Depending on the value of CMAKE_BUILD_TYPE and BUILD_SHARED_LIBS,
# this variable will be set with the requested value.
# (e.g., if ``CMAKE_BUILD_TYPE`` is ``Release`` and ``BUILD_SHARED_LIBS`` is
# ``OFF``, will have the same value as
# ``CONNEXTDDS_C_API_LIBRARIES_RELEASE_STATIC``).
#
# Also, the ``<VAR>_FOUND`` variable is set for each one of the previous
# variables.
#
# The list of libraries for each component is the following:
#
# - ``core`` component (always set by this module):
# - ``CONNEXTDDS_C_API``
# (e.g., ``CONNEXTDDS_C_API_LIBRARIES_RELEASE_STATIC``)
# - ``CONNEXTDDS_CPP_API``
# (e.g., ``CONNEXTDDS_CPP_API_LIBRARIES_RELEASE_STATIC``)
# - ``CONNEXTDDS_CPP2_API``
# (e.g., ``CONNEXTDDS_CPP2_API_LIBRARIES_RELEASE_STATIC``)
# - ``METP``
# (e.g., ``METP_LIBRARIES_RELEASE_STATIC``)
# - ``RTIXML2``
# (e.g., ``RTIXML2_LIBRARIES_RELEASE_STATIC``)
# - ``RTIAPPUTILS_C``
# (e.g., ``RTIAPPUTILS_C_LIBRARIES_RELEASE_STATIC``)
# - ``RTISQLITE``
# (e.g., ``RTISQLITE_LIBRARIES_RELEASE_STATIC``)
#
# - ``test`` component:
# - ``RTITEST``
# (e.g., ``RTITEST_LIBRARIES_RELEASE_STATIC``)
#
# - ``test_helpers`` component:
# - ``NDDS_TEST_HELPERS``
# (e.g., ``NDDS_TEST_HELPERS_LIBRARIES_RELEASE_STATIC``)
#
# - ``distributed_loger`` component:
# - ``DISTRIBUTED_LOGGER_C``
# (e.g., ``DISTRIBUTED_LOGGER_C_LIBRARIES_RELEASE_STATIC)
# - ``DISTRIBUTED_LOGGER_CPP``
# (e.g., ``DISTRIBUTED_LOGGER_CPP_LIBRARIES_RELEASE_STATIC)
# - ``DISTRIBUTED_LOGGER_CPP2``
# (e.g., ``DISTRIBUTED_LOGGER_CPP2_LIBRARIES_RELEASE_STATIC)
#
# - ``messaging_api`` component:
# - ``MESSAGING_C``
# (e.g., ``MESSAGING_C_API_LIBRARIES_RELEASE_STATIC``)
# - ``MESSAGING_CPP``
# (e.g., ``MESSAGING_CPP_API_LIBRARIES_RELEASE_STATIC``)
# - ``MESSAGING_CPP2``
# (e.g, ``MESSAGING_CPP2_API_LIBRARIES_RELEASE_STATIC``)
#
# - ``routing_service`` component:
# - ``ROUTING_SERVICE_API``
# (e.g., ``ROUTING_SERVICE_API_LIBRARIES_RELEASE_STATIC``)
# - ``ROUTING_SERVICE_INFRASTRUCTURE``
# (e.g., ``ROUTING_SERVICE_INFRASTRUCTURE_LIBRARIES_RELEASE_STATIC``)
# - ``ASSIGN_TRANSFORMATION``
# (e.g., ``ASSIGN_TRANSFORMATION_LIBRARIES_RELEASE_STATIC``)
#
# - ``security_plugins`` component:
# - ``SECURITY_PLUGINS``
# (e.g., ``SECURITY_PLUGINS_LIBRARIES_RELEASE_STATIC``)
#
# - ``monitoring_libraries`` component:
# - ``MONITORING_LIBRARIES``
# (e.g., ``MONITORING_LIBRARIES_RELEASE_STATIC``)
#
# - ``nddstls`` component:
# - ``NDDSTLS``
# (e.g., ``NDDSTLS_LIBRARIES_RELEASE_STATIC``)
#
# - ``transport_tcp`` component:
# - ``TRANSPORT_TCP``
# (e.g., ``TRANSPORT_TCP_LIBRARIES_RELEASE_STATIC``)
#
# - ``transport_tls`` component:
# - ``TRANSPORT_TLS``
# (e.g., ``TRANSPORT_TLS_LIBRARIES_RELEASE_STATIC``)
#
# - ``transport_wan`` component:
# - ``TRANSPORT_WAN``
# (e.g., ``TRANSPORT_WAN_LIBRARIES_RELEASE_STATIC``)
#
# - ``recording_service`` component:
# - ``RECORDING_SERVICE_API``
# (e.g., ``RECORDING_SERVICE_API_LIBRARIES_RELEASE_STATIC``)
#
# - ``cloud_discovery_service`` component:
# - ``CLOUD_DISCOVERY_SERVICE_API_C``
# (e.g., ``CLOUD_DISCOVERY_SERVICE_API_C_LIBRARIES_RELEASE_STATIC``)
# - ``CLOUD_DISCOVERY_SERVICE_API_CPP``
# (e.g., ``CLOUD_DISCOVERY_SERVICE_API_CPP_LIBRARIES_RELEASE_STATIC``)
#
# - ``persistence_service`` component:
# - ``PERSISTENCE_SERVICE_API_C``
# (e.g., ``PERSISTENCE_SERVICE_API_C_LIBRARIES_RELEASE_STATIC``)
#
# - ``web_integration_service`` component:
# - ``WEB_INTEGRATION_SERVICE_API_CPP2``
# (e.g., ``WEB_INTEGRATION_SERVICE_API_CPP2_LIBRARIES_RELEASE_STATIC``)
#
# - ``low_bandwidth_plugins`` component:
# - ``LOW_BANDWIDTH_DISCOVERY_STATIC``
# (e.g., ``LOW_BANDWIDTH_DISCOVERY_STATIC_LIBRARIES_RELEASE_STATIC``)
# - ``LOW_BANDWIDTH_EDISC``
# (e.g., ``LOW_BANDWIDTH_EDISC_LIBRARIES_RELEASE_STATIC``)
# - ``LOW_BANDWIDTH_PDISC``
# (e.g., ``LOW_BANDWIDTH_PDISC_LIBRARIES_RELEASE_STATIC``)
# - ``LOW_BANDWIDTH_RTPS``
# (e.g., ``LOW_BANDWIDTH_RTPS_LIBRARIES_RELEASE_STATIC``)
# - ``LOW_BANDWIDTH_SM``
# (e.g., ``LOW_BANDWIDTH_SM_LIBRARIES_RELEASE_STATIC``)
# - ``LOW_BANDWIDTH_ST``
# (e.g., ``LOW_BANDWIDTH_ST_LIBRARIES_RELEASE_STATIC``)
#
# - ``rtizrtps`` component:
# - ``RTIZRTPS``
# (e.g., ``RTIZRTPS_LIBRARIES_RELEASE_STATIC``)
#
# Also, the ``<VAR>_FOUND`` variable is set for each one of the previous
# variables (e.g., ``MONITORING_LIBRARIES_RELEASE_STATIC_FOUND`` and
# ``MONITORING_LIBRARIES_FOUND`` are set).
#
# If you are building a simple ConnextDDS application (you are only using
# the core libraries), use the following variables:
#
# - For a C application: CONNEXTDDS_C_API
# - For a Traditional C++ application: CONNEXTDDS_CPP_API
# - For a Modern C++ application: CONNEXTDDS_CPP2_API
#
# Lastly, if you want to use the security plugins (or any other component),
# add the appropriate variables to your CMake script.
#
# Hints
# ^^^^^
# If the find_package invocation specifies a version, this module will try
# to find your Connext installation in the default installation
# directories. Likewise, the module will try to guess the name of the
# architecture you are trying to build against, by looking for it under the
# rti_connext_dds-x.y.z/lib.
#
# However, in some cases you must provide the following hints by defining some
# variables in your cmake invocation:
#
# - If you don't specify a version or you have installed Connext in a
# non-default location, you must set the ``CONNEXTDDS_DIR`` pointing to your
# RTI Connext installation folder. For example:
# cmake -DCONNEXTDDS_DIR=/home/rti/rti_connext_dds-x.y.z
#
# - If you have installed more than one architecture on your system (i.e., more
# than one target rtipkg), you must set the ``CONNEXTDDS_ARCH`` to provide
# the name of the architecture. For example:
# cmake -DCONNEXTDDS_ARCH=x64Linux3gcc5.4.0
#
# - If you are building against the security_plugins component, this module
# will try to find OpenSSL in your system using find_package(OpenSSL). If you
# want to build against a specific installation of OpenSSL, you must set the
# ``CONNEXTDDS_OPENSSL_DIR`` to provide this module with the path to your
# installation of OpenSSL. This variable has to be populated with the OpenSSL
# root directory, e.g.:
# <CONNEXTDDS_DIR>/third_party/openssl-<version>/<architecture>/release/
#
# Besides that, if you are building against the security_plugins component and
# you want to ensure that you are using a specific OpenSSL version, you must
# set the ``CONNEXTDDS_OPENSSL_VERSION`` so that it can be added to the
# find_package(OpenSSL) invocation.
#
# Likewise, if instead of security_plugins you use security_plugins_wolfssl,
# you will use the variables ``CONNEXTDDS_WOLFSSL_DIR`` and
# ``CONNEXTDDS_WOLFSSL_VERSION``
#
# - To control the Connext libraries build type you will need to use the
# ``CONNEXT_LIBS_BUILD_TYPE`` CMake variable. By default the imported target
# libraries will be provided with the build type in use (the ``Auto`` value).
# If you want to force a specific build type (Release or Debug) of the Connext
# libraries, you will have to set the ``CONNEXT_LIBS_BUILD_TYPE`` CMake
# variable. Example:
# cmake -DCONNEXT_LIBS_BUILD_TYPE=Release
#
# Take into account that forcing Release or Debug libraries could result in
# errors when building the opposite build type (e.g.: using
# ``-DCONNEXT_LIBS_BUILD_TYPE=Release`` and building with
# ``cmake --build . --config Debug``). Mixing Connext Release and Debug
# libraries can result in build errors or application problems like
# double-freeing memory (once for the Debug symbol and another for the
# Release one).
#
# Note
# ^^^^
# Some flags related to the compiler, (such as -std=c++11, needed when linking
# against the CPP2 libraries) will not be provided by this script. These flags
# should be provided by the build system.
#
# Examples
# ^^^^^^^^
# Simple Connext application
# ::
# cmake_minimum_required(VERSION 3.11)
# project (example)
# set(CMAKE_MODULE_PATH
# ${CMAKE_MODULE_PATH}
# "/home/rti/rti_connext_dds-6.0.0/resource/cmake")
#
# find_package(RTIConnextDDS EXACT "6.0.0" REQUIRED)
#
# set(SOURCES_PUB
# "src/HelloWorld_publisher.c"
# "src/HelloWorld.c"
# "src/HelloWorldPlugin.c"
# "src/HelloWorldSupport.c"
# )
#
# add_executable(HelloWorld_c_publisher ${SOURCES_PUB})
# target_link_libraries(HelloWorld_c_publisher
# PUBLIC
# RTIConnextDDS::c_api
# )
#
#
# Simple Routing Service adapter
# ::
# cmake_minimum_required(VERSION 3.11)
# project (example)
# set(CMAKE_MODULE_PATH
# ${CMAKE_MODULE_PATH}
# "/home/rti/rti_connext_dds-6.0.0/resource/cmake")
#
# find_package(RTIConnextDDS
# EXACT "6.0.0"
# REQUIRED
# COMPONENTS
# routing_service
# )
#
# set(LIBRARIES
# ${ROUTING_SERVICE_API_LIBRARIES_RELEASE_STATIC}
# ${CONNEXTDDS_EXTERNAL_LIBS}
# )
#
# set(SOURCES_LIB
# "src/FileAdapter.c"
# "src/LineConversion.c"
# "src/osapi.c"
# )
#
# add_library(shapestransf ${SOURCES_LIB})
# target_link_libraries(shapestransf
# PUBLIC
# RTIConnextDDS::routing_service
# )
#
# Supported platforms
# ^^^^^^^^^^^^^^^^^^^
# Oficially, this FindPackage supports the following platforms listed in the
# RTI Connext Core Libraries Platform Notes:
#
# - Linux platforms: x64
# - Darwin platforms: macOS x64 (10.13-10.15, 11-13) and ARMv8 (11-13)
# - Windows platforms: x64, ARM64
# - QNX platforms (7.0 and 7.1): x64 and ARMv8
#
# Other platforms and architectures might work, but they are not oficially
# supported.
#
# Toolchain examples
# ^^^^^^^^^^^^^^^^^^
# In order to build against cross-compiled architectures a toolchain file is
# needed. This file will contain all the necessary information about the
# compiler and other utility paths. To use a toolchain file in the build the
# following variable must be provided in the command
# ::
#
# cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain_file_path>.cmake <source_dir>/
#
# QNX
# """
# ARMv8 QNX 7.1 gpp sample toolchain file
# ::
#
# set(CMAKE_SYSTEM_NAME QNX)
# set(CMAKE_SYSTEM_VERSION 7.1)
# set(CMAKE_SYSTEM_PROCESSOR armv8)
#
# set(tools_dir "$ENV{QNX_HOST}/usr/bin")
# set(CMAKE_C_COMPILER "${tools_dir}/qcc")
# set(CMAKE_CXX_COMPILER "${CMAKE_C_COMPILER}")
# set(CMAKE_C_COMPILER_TARGET "8.3.0,gcc_ntoaarch64le_gpp")
# set(CMAKE_CXX_COMPILER_TARGET "${CMAKE_C_COMPILER_TARGET}")
# set(CMAKE_LINKER "${CMAKE_C_COMPILER}" CACHE PATH "")
# set(CMAKE_AR "${tools_dir}/ntoaarch64-ar" CACHE PATH "")
#
# set(PLATFORM_MODERN_CXX_STANDARD 11)
# set(CMAKE_CXX_EXTENSIONS TRUE)
#
# Logging in versions lower than CMake 3.15
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# For versions lower than CMake 3.15, the ``CONNEXTDDS_LOG_LEVEL`` variable
# should be used to define logging levels lower than ``STATUS`` mode. All these
# modes will show messages of current level and higher. The following modes are
# available:
#
# - ``STATUS``
# Default mode. This will olnly show messages with same or higher logging
# level than CMake ``STATUS``.
# - ``VERBOSE``
# This mode will show all messages from ``VERBOSE`` level and higher.
# - ``DEBUG``
# This last mode will show messages from all previous levels and ``DEBUG``.
include(CMakeParseArguments)
# Starting wiht CMake 3.12, find_package function calls searches for prefixes
# specified by the <PackageName>_ROOT variable and its corresponding environment
# variable. The OLD behaviour is to ignore those kind of variables, so we set
# the policy to NEW.
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
# Starting with CMake 3.3, the support for the IN_LIST operator in the if block
# was added. The OLD behaviour is to ignore this operator, so we set the policy
# to NEW.
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()
#####################################################################
# Global Variables #
#####################################################################
set(CONNEXT_LIBS_BUILD_TYPE_LIST "Release" "Debug" "Auto")
set(CONNEXT_LIBS_BUILD_TYPE "Auto" CACHE STRING
"Connext imported target libraries build type to use"
)
if(CONNEXTDDS_IMPORTED_TARGETS_DEBUG)
message(DEPRECATION
"CONNEXTDDS_IMPORTED_TARGETS_DEBUG variable will be deprecated in the"
" future. Set the CONNEXT_LIBS_BUILD_TYPE variable value to Debug"
"to get the same behavior."
)
set(CONNEXT_LIBS_BUILD_TYPE "Debug")
endif()
if(NOT CONNEXT_LIBS_BUILD_TYPE IN_LIST CONNEXT_LIBS_BUILD_TYPE_LIST)
message(FATAL_ERROR
"Ensure the CONNEXT_LIBS_BUILD_TYPE value is one of Auto, Release or"
" Debug without quotes"
)
endif()
#####################################################################
# Logging Macros #
#####################################################################
# These two macros allow better code tracing with debug and verbose messages
# using new CMake 3.15 message types. If CMake 3.14 or lower is in use,
# default messages will be displayed starting with ``DEBUG`` or ``VERBOSE``
# instead.
#
# Arguments:
# - message: provides the text message
if("${CMAKE_MINOR_VERSION}" GREATER_EQUAL "15")
macro(connextdds_log_verbose)
message(VERBOSE "VERBOSE " ${ARGN})
endmacro()
macro(connextdds_log_debug)
message(DEBUG " DEBUG " ${ARGN})
endmacro()
else()
set(CONNEXTDDS_LOG_LEVEL_LIST "STATUS" "VERBOSE" "DEBUG")
if(NOT CONNEXTDDS_LOG_LEVEL)
set(CONNEXTDDS_LOG_LEVEL "STATUS")
endif()
if(NOT CONNEXTDDS_LOG_LEVEL IN_LIST CONNEXTDDS_LOG_LEVEL_LIST)
string(REPLACE ";"
" " LOG_LEVELS_STRING
"${CONNEXTDDS_LOG_LEVEL_LIST}")
message(FATAL_ERROR "Log level must be one of: ${LOG_LEVELS_STRING}. "
"It's default value is STATUS.")
endif()
macro(connextdds_log_verbose)
if("${CONNEXTDDS_LOG_LEVEL}" MATCHES "VERBOSE|DEBUG")
message(STATUS "VERBOSE " ${ARGN})
endif()
endmacro()
macro(connextdds_log_debug)
if("${CONNEXTDDS_LOG_LEVEL}" STREQUAL "DEBUG")
message(STATUS " DEBUG " ${ARGN})
endif()
endmacro()
endif()
# This macro allow xml login with previous ``VERBOSE`` loger macros.
#
# Arguments:
# - XML_NAME: provides the name of the xml
# - XML: provides the xml contents
macro(connextdds_log_xml XML_NAME XML)
string(REPLACE "\n"
";" lines
${XML})
connextdds_log_verbose("~~~~~~~START ${XML_NAME}~~~~~~~")
foreach(line ${lines})
connextdds_log_verbose("\t${line}")
endforeach()
connextdds_log_verbose("~~~~~~~FINISH ${XML_NAME}~~~~~~~")
endmacro()
#####################################################################
# Preconditions Check #
#####################################################################
#
# Find RTI Connext installation. We provide some hints that include the
# CONNEXTDDS_DIR variable, the $NDDSHOME environment variable, and the
# default installation directories.
if(NOT CONNEXTDDS_DIR)
connextdds_log_verbose("CONNEXTDDS_DIR not specified")
# Is a patch
if(PACKAGE_FIND_VERSION_COUNT EQUAL 4)
set(folder_version
"${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}.${PACKAGE_FIND_VERSION_PATCH}"
)
connextdds_log_debug("The required ConnextDDS version is a patch")
else()
set(folder_version ${RTIConnextDDS_FIND_VERSION})
endif()
connextdds_log_verbose("ConnextDDS version ${folder_version}")
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
set(connextdds_root_hints
"$ENV{HOME}/rti_connext_dds-${folder_version}"
)
set(connextdds_root_paths
"$ENV{HOME}/rti_connext_dds-*"
)
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
set(connextdds_root_hints
"C:/Program Files (x86)/rti_connext_dds-${folder_version}"
"C:/Program Files/rti_connext_dds-${folder_version}"
"C:/rti_connext_dds-${folder_version}"
)
set(connextdds_root_paths
"C:/Program Files (x86)/rti_connext_dds-*"
"C:/Program Files/rti_connext_dds-*"
"C:/rti_connext_dds-*"
)
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
set(connextdds_root_hints
"/Applications/rti_connext_dds-${folder_version}"
)
set(connextdds_root_paths
"/Applications/rti_connext_dds-*"
)
endif()
file(GLOB connextdds_root_paths_expanded
LIST_DIRECTORIES TRUE
${connextdds_root_paths}
)
connextdds_log_debug("Root hints: ${connextdds_root_hints}")
connextdds_log_debug("Root paths: ${connextdds_root_paths_expanded}")
endif()
# We require having an rti_versions file under the installation directory
# as we will use it to verify that the version is appropriate.
find_path(CONNEXTDDS_DIR
NAMES
"rti_versions.xml"
HINTS
"${NDDSHOME}"
ENV CONNEXTDDS_DIR
ENV NDDSHOME
# ``FindRTIConnextDDS.cmake`` is located under ``resources/cmake`` in
# the ConnextDDS installation
"${CMAKE_CURRENT_LIST_DIR}/../../"
${connextdds_root_hints}
PATHS
${connextdds_root_paths_expanded}
)
if(NOT CONNEXTDDS_DIR)
set(error
"CONNEXTDDS_DIR not specified. Please set -DCONNEXTDDS_DIR= to "
"your RTI Connext installation directory"
)
message(FATAL_ERROR ${error})
endif()
message(STATUS "RTI Connext installation directory: ${CONNEXTDDS_DIR}")
set(codegen_name "rtiddsgen")
if(WIN32)
set(codegen_name "${codegen_name}.bat")
endif()
connextdds_log_debug("Codegen script ${codegen_name}")
find_path(RTICODEGEN_DIR
NAME "${codegen_name}"
HINTS
"${CONNEXTDDS_DIR}/bin"
ENV RTICODEGEN_DIR
)
if(NOT RTICODEGEN_DIR)
set(warning
"Codegen was not found. Please, check if rtiddsgen is under your "
"NDDSHOME/bin directory or provide it to CMake using -DRTICODEGEN_DIR"
)
message(WARNING ${warning})
else()
find_program(RTICODEGEN
NAME
"${codegen_name}"
HINTS
${RTICODEGEN_DIR}
DOC "Path to RTI Codegen"
)
# Execute RTI Code Generator to get the version
connextdds_log_debug("Get the Codegen version: '${RTICODEGEN} -version'")
execute_process(
COMMAND
${RTICODEGEN} -version
OUTPUT_VARIABLE codegen_version_string
)
# Sanitize Codegen output. When run for the first time, it shows some paths
# and CMake doesn't like Windows paths
string(REPLACE "\\" "/" codegen_version_string "${codegen_version_string}")
connextdds_log_debug("Command output:")
connextdds_log_debug("${codegen_version_string}")
# Instead of searching for a version (also found in the NDDSHOME directory
# showed by Codegen when run for the first time), try to match a safer
# string and then select the matching group for the version
string(REGEX MATCH
"rtiddsgen version ([0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?)"
_ "${codegen_version_string}"
)
set(RTICODEGEN_VERSION "${CMAKE_MATCH_1}")
connextdds_log_verbose("Codegen version: ${RTICODEGEN_VERSION}")
endif()
# Find RTI Connext architecture if CONNEXTDDS_ARCH is unset
if(NOT CONNEXTDDS_ARCH)
connextdds_log_verbose("CONNEXTDDS_ARCH was not provided")
# Guess the RTI Connext architecture
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
string(REGEX REPLACE "^([0-9]+).*$" "\\1"
major_version
"${CMAKE_CXX_COMPILER_VERSION}"
)
set(version_compiler "${major_version}.0")
connextdds_log_debug("Compiler version: ${version_compiler}")
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1"
kernel_version "${CMAKE_SYSTEM_VERSION}")
connextdds_log_debug("Kernel version: ${kernel_version}")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64")
set(guessed_architecture
"arm64Darwin${kernel_version}${version_compiler}"
)
else()
set(guessed_architecture
"x64Darwin${kernel_version}${version_compiler}"
)
endif()
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86")
set(connextdds_host_arch "i86Win32")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64")
set(connextdds_host_arch "x64Win64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ARM64")
set(connextdds_host_arch "arm64Win64")
else()
message(FATAL_ERROR
"${CMAKE_HOST_SYSTEM} is not supported as host architecture")
endif()
connextdds_log_debug("Host architecture: ${connextdds_host_arch}")
string(REGEX MATCH "[0-9][0-9][0-9][0-9]"
vs_year
"${CMAKE_GENERATOR}"
)
connextdds_log_debug("Visual Studio year: ${vs_year}")
set(guessed_architecture "${connextdds_host_arch}VS${vs_year}")
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
if(CMAKE_COMPILER_VERSION VERSION_EQUAL "4.6.3")
set(kernel_version "3.x")
else()
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1"
kernel_version
"${CMAKE_SYSTEM_VERSION}"
)
endif()
connextdds_log_debug("Kernel version: ${kernel_version}")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
set(connextdds_host_arch "x64Linux")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i686")
set(connextdds_host_arch "i86Linux")
endif()
connextdds_log_debug("Host architecture: ${connextdds_host_arch}")
set(guessed_architecture
"${connextdds_host_arch}${kernel_version}gcc${CMAKE_C_COMPILER_VERSION}")
endif()
connextdds_log_verbose("Guessed RTI architecture: ${guessed_architecture}")
if(DEFINED ENV{CONNEXTDDS_ARCH})
file(TO_CMAKE_PATH "$ENV{CONNEXTDDS_ARCH}" CONNEXTDDS_ARCH)
elseif(EXISTS "${CONNEXTDDS_DIR}/lib/${guessed_architecture}")
set(CONNEXTDDS_ARCH "${guessed_architecture}")
connextdds_log_debug("${CONNEXTDDS_DIR}/lib/${guessed_architecture} exists")
else()
# If CONNEXTDDS_ARCH is unspecified, the module tries uses the first
# architecture installed by looking under $CONNEXTDDS_DIR/lib.
file(GLOB architectures_installed
RELATIVE "${CONNEXTDDS_DIR}/lib"
"${CONNEXTDDS_DIR}/lib/*")
foreach(architecture_name ${architectures_installed})
if(architecture_name STREQUAL "java")
# Because the lib folder contains both target libraries and
# Java JAR files, here we exclude the "java" in our algorithm
# to guess the appropriate CONNEXTDDS_ARCH variable.
continue()
elseif(NOT "${architecture_name}" MATCHES "^[A-Za-z0-9]")
# Sometimes, some hidden or temporary folders/files are
# created. We skip them
continue()
elseif("${architecture_name}" MATCHES ${CMAKE_HOST_SYSTEM_NAME})
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
# Get the installed Darwin
set(CONNEXTDDS_ARCH "${architecture_name}")
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86" AND
"${architecture_name}" MATCHES "Win32")
# Get the x86Win32 architecture
set(CONNEXTDDS_ARCH "${architecture_name}")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" AND
"${architecture_name}" MATCHES "x64Win64")
# Get the x64Win64 architecture
set(CONNEXTDDS_ARCH "${architecture_name}")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ARM64" AND
"${architecture_name}" MATCHES "arm64Win64")
# Get the arm64Win64 architecture
set(CONNEXTDDS_ARCH "${architecture_name}")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i686" AND
"${architecture_name}" MATCHES "x86Linux")
# Get the x86Linux architecture
set(CONNEXTDDS_ARCH "${architecture_name}")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64" AND
"${architecture_name}" MATCHES "x64Linux")
# Get the x64Linux architecture
set(CONNEXTDDS_ARCH "${architecture_name}")
endif()
endif()
endif()
if(CONNEXTDDS_ARCH)
break()
endif()
endforeach()
if(NOT CONNEXTDDS_ARCH)
message(WARNING
"CONNEXTDDS_ARCH not specified. Please set "
"-DCONNEXTDDS_ARCH= to specify your RTI Connext "
" architecture")
endif()
endif()
endif()
message(STATUS "RTI Connext architecture: ${CONNEXTDDS_ARCH}")
#####################################################################
# Helper Functions #
#####################################################################
# Checks that a certain field associated with a component is installed under
# CONNEXTDDS_DIR and that its version is consistent with the version required
# for the rest of modules. If RTICONNEXTDDS_VERSION, the version variable, is
# specified, then it checks that the value is consistent. Otherwise,
# it sets the value of RTICONNEXTDDS_VERSION so that it can be checked in
# future calls of this function to validate that its value is consistent
# accross fields and components.
#
# At the end of the script CMake will check that RTICONNEXTDDS_VERSION is
# consistent with the version specified by the user in the find_package
# invocation, acording to the matching rules defined by CMake.
#
# Arguments:
# - field_name: provides the name of the xml tag to search.
# - rti_versions_file: contents of the rti_versions.xml file.
# - rti_architectures: list of architectures to search if present in the
# rti_versions.xml file
# Returns:
# - A warning is shown and the `rtiversion_error` variable will be set if the
# component field is not present in rti_versions.xml or the version does not
# match RTICONNEXTDDS_VERSION.
function(connextdds_check_component_field_version
field_name
rti_versions_file
rti_architectures)
connextdds_log_debug("connextdds_check_component_field_version called")
connextdds_log_debug(
"====================================================================")
connextdds_log_debug("\tfield_name: ${field_name}")
connextdds_log_debug("\trti_architectures: [${${rti_architectures}}]")
connextdds_log_verbose("Checking version for ${field_name}")
# Get the component info
set(field_section_regex "<${field_name}>.*</${field_name}>")
string(REGEX MATCH ${field_section_regex} field_xml "${rti_versions_file}")
connextdds_log_xml("Component info:" "${field_xml}")
# Check all the architectures defined in the component
foreach(architecture IN LISTS ${rti_architectures})
# Ignore java fro routing_service_host
if(architecture STREQUAL "java" AND
field_name STREQUAL "routing_service_host")
continue()
endif()
string(CONCAT field_arch_regex
"<installation>[\n\r\t ]*"
"<architecture>${architecture}.*</architecture>"
"[\n\r\t ]*<version>[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?"
"</version>")
string(REGEX MATCH ${field_arch_regex} field_arch "${field_xml}")
if(field_arch)
connextdds_log_xml("Field arch:" "${field_arch}")
break()
endif()
endforeach()
if(NOT field_arch)
message(WARNING
"${field_name} is not installed for ${CONNEXTDDS_ARCH} "
"under ${CONNEXTDDS_DIR}")
set(rtiversion_error TRUE PARENT_SCOPE)
endif()
# Get the <version> tag from the component
set(field_version_regex
"<version>[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?</version>")
string(REGEX MATCH ${field_version_regex} field_version "${field_arch}")
connextdds_log_xml("Component version tag:" "${field_version}")
if(NOT field_version)
set(rtiversion_error TRUE PARENT_SCOPE)
message(WARNING
"The version tag was not extracted from ${field_name} and "
"${CONNEXTDDS_ARCH} under ${CONNEXTDDS_DIR}")
return()
endif()
# Extract the version string from the tag
set(field_version_number_regex
"[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?")
string(REGEX MATCH
${field_version_number_regex}
field_version_number
${field_version})
connextdds_log_xml("Component version:" "${field_version_number}")
if(NOT field_version_number)
set(rtiversion_error TRUE PARENT_SCOPE)
message(WARNING
"The version number was not extracted from ${field_name} and "
"${CONNEXTDDS_ARCH} under ${CONNEXTDDS_DIR}")
return()
endif()
if(NOT "${RTICONNEXTDDS_VERSION}" VERSION_EQUAL "${field_version_number}")
# Otherwise, if the detected version is inconsistent with the previous
# value of RTICONNEXTDDS_VERSION, we throw an error.
set(warning
"The version of ${field} is ${field_version_number}, which "
"is incosistent with the expected version... "
"${RTICONNEXTDDS_VERSION}")
message(WARNING ${warning})
set(rtiversion_error TRUE PARENT_SCOPE)
else()
connextdds_log_verbose("${field_name} version.........OK")
endif()
connextdds_log_debug(