-
Notifications
You must be signed in to change notification settings - Fork 44
/
CMakeLists.txt
841 lines (802 loc) · 27.4 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
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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
cmake_minimum_required(VERSION 3.10.2)
project(iotfleetwise VERSION 1.2.0)
# FWE uses C++14 for compatibility reasons with Automotive middlewares (Adaptive AUTOSAR, ROS2)
# Note: When built with FWE_FEATURE_ROS2, colcon will override these settings
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Print out the compile commands which is useful for IDEs
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# All build and configuration options are prefaced with FWE_
option(FWE_STATIC_LINK "Statically link external libs" OFF)
option(FWE_CODE_COVERAGE "Enables code coverage" OFF)
option(FWE_VALGRIND "Enable valgrind tests" OFF)
option(FWE_BUILD_DOC "Build documentation" ON)
option(FWE_STRIP_SYMBOLS "Strips symbols from output binaries" OFF)
option(FWE_TEST_CLANG_TIDY "Add clang-tidy test" ON)
option(FWE_TEST_FAKETIME "Enable tests that use the faketime library" OFF)
option(FWE_WERROR "Enable -Werror compiler flag" OFF)
option(FWE_SECURITY_COMPILE_FLAGS "Add security related compile options" OFF)
option(FWE_AWS_SDK_SHARED_LIBS "Use AWS SDK shared libs. Needs to be set to the same value of BUILD_SHARED_LIBS that the SDK was compiled with." OFF)
option(FWE_AWS_SDK_EXTRA_LIBS "Extra libs required to link with the AWS SDK. When FWE_STATIC_LINK is ON, setting this to ON will automatically find the standard libs. Can be a space-separated list of libs." ON)
option(FWE_FEATURE_GREENGRASSV2 "Enable Greengrass connection module" OFF)
option(FWE_FEATURE_IWAVE_GPS "Include the IWave GPS example" OFF)
option(FWE_FEATURE_EXTERNAL_GPS "Include the external GPS example" OFF)
option(FWE_FEATURE_AAOS_VHAL "Include the Android Automotive VHAL example" OFF)
option(FWE_FEATURE_S3 "Internal option, not useful on its own. Enables usage of AWS credential provider, and uploading and downloading from S3." OFF)
option(FWE_FEATURE_VISION_SYSTEM_DATA "Include support for vision-system-data sources. Implies FWE_FEATURE_S3." OFF)
option(FWE_FEATURE_ROS2 "Include support for ROS2 as a vision-system-data source. Implies FWE_FEATURE_VISION_SYSTEM_DATA." OFF)
option(FWE_FEATURE_SOMEIP "Include the example SOME/IP data source, the example SOME/IP to CAN bridge, the example SOME/IP command dispatcher, and the example SOME/IP to device shadow proxy. Implies FWE_FEATURE_REMOTE_COMMANDS." OFF)
option(FWE_FEATURE_REMOTE_COMMANDS "Include support for remote commands" OFF)
option(FWE_FEATURE_LAST_KNOWN_STATE "Include support for last known state. Implies FWE_FEATURE_REMOTE_COMMANDS." OFF)
option(FWE_FEATURE_STORE_AND_FORWARD "Include support for store and forward" OFF)
option(FWE_FEATURE_CUSTOM_FUNCTION_EXAMPLES "Include the custom function examples" OFF)
option(FWE_BUILD_EXECUTABLE "Build the executable, otherwise build a library" ON)
option(FWE_BUILD_ANDROID_SHARED_LIBRARY "Build the android shared library" OFF)
option(FWE_BUILD_TOOLS "Build helper tools" ON)
option(FWE_FEATURE_UDS_DTC "Enable UDS DTC information collection" OFF)
option(FWE_FEATURE_UDS_DTC_EXAMPLE "Include example UDS DTC interface for collecting UDS DTC information. Implies FWE_FEATURE_UDS_DTC." OFF)
if(FWE_FEATURE_IWAVE_GPS)
add_compile_options("-DFWE_FEATURE_IWAVE_GPS")
endif()
if(FWE_FEATURE_EXTERNAL_GPS)
add_compile_options("-DFWE_FEATURE_EXTERNAL_GPS")
endif()
if(FWE_FEATURE_AAOS_VHAL)
add_compile_options("-DFWE_FEATURE_AAOS_VHAL")
endif()
if(FWE_FEATURE_GREENGRASSV2)
add_compile_options("-DFWE_FEATURE_GREENGRASSV2")
endif()
if(FWE_FEATURE_ROS2)
set(FWE_FEATURE_VISION_SYSTEM_DATA ON FORCE)
add_compile_options("-DFWE_FEATURE_ROS2")
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(fastcdr REQUIRED)
ament_package()
endif()
if(FWE_FEATURE_VISION_SYSTEM_DATA)
set(FWE_FEATURE_S3 ON FORCE)
add_compile_options("-DFWE_FEATURE_VISION_SYSTEM_DATA;-DDECNUMDIGITS=34")
endif()
if(FWE_FEATURE_SOMEIP)
set(FWE_FEATURE_REMOTE_COMMANDS ON FORCE)
add_compile_options("-DFWE_FEATURE_SOMEIP")
endif()
if(FWE_FEATURE_LAST_KNOWN_STATE)
set(FWE_FEATURE_REMOTE_COMMANDS ON FORCE)
add_compile_options("-DFWE_FEATURE_LAST_KNOWN_STATE")
endif()
if(FWE_FEATURE_REMOTE_COMMANDS)
add_compile_options("-DFWE_FEATURE_REMOTE_COMMANDS")
endif()
if(FWE_FEATURE_STORE_AND_FORWARD)
find_path(STORE_LIBRARY_CPP_INCLUDE_DIR "stream/stream.hpp" PATH_SUFFIXES "aws/store")
find_library(STORE_LIBRARY_CPP_STREAM NAMES stream)
find_library(STORE_LIBRARY_CPP_KV NAMES kv)
add_compile_options("-DFWE_FEATURE_STORE_AND_FORWARD")
endif()
if(FWE_FEATURE_UDS_DTC_EXAMPLE)
set(FWE_FEATURE_UDS_DTC ON FORCE)
add_compile_options("-DFWE_FEATURE_UDS_DTC_EXAMPLE")
endif()
if(FWE_FEATURE_UDS_DTC)
add_compile_options("-DFWE_FEATURE_UDS_DTC")
endif()
if(FWE_FEATURE_CUSTOM_FUNCTION_EXAMPLES)
add_compile_options("-DFWE_FEATURE_CUSTOM_FUNCTION_EXAMPLES")
endif()
if(FWE_FEATURE_S3)
add_compile_options("-DFWE_FEATURE_S3")
endif()
# Define the default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
include(cmake/compiler_gcc.cmake)
include(GNUInstallDirs)
if(FWE_BUILD_DOC)
include(cmake/graphviz.cmake)
include(cmake/doxygen.cmake)
endif()
include(CTest)
if(BUILD_TESTING)
include(cmake/unit_test.cmake)
include(cmake/valgrind.cmake)
include(cmake/clang_tidy.cmake)
endif()
if(FWE_FEATURE_SOMEIP)
include(cmake/capicxx_gen.cmake)
endif()
# Disallow cycles
set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES ON)
# Version
execute_process(COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}" rev-parse HEAD
OUTPUT_VARIABLE VERSION_GIT_SHA
ERROR_QUIET)
execute_process(COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}" describe --tags --abbrev=0
OUTPUT_VARIABLE VERSION_GIT_TAG
ERROR_QUIET)
string(STRIP "${VERSION_GIT_SHA}" VERSION_GIT_SHA)
string(STRIP "${VERSION_GIT_TAG}" VERSION_GIT_TAG)
string(TIMESTAMP VERSION_CURRENT_TIME "%Y-%m-%d %H:%M:%S" UTC)
configure_file(src/IoTFleetWiseVersion.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/IoTFleetWiseVersion.cpp)
# Protobuf
find_package(Protobuf REQUIRED)
set(PROTO_FILES
interfaces/protobuf/schemas/cloudToEdge/common_types.proto
interfaces/protobuf/schemas/cloudToEdge/collection_schemes.proto
interfaces/protobuf/schemas/cloudToEdge/decoder_manifest.proto
interfaces/protobuf/schemas/edgeToCloud/checkin.proto
interfaces/protobuf/schemas/edgeToCloud/vehicle_data.proto
)
if(FWE_FEATURE_REMOTE_COMMANDS)
set(PROTO_FILES ${PROTO_FILES}
interfaces/protobuf/schemas/cloudToEdge/command_request.proto
interfaces/protobuf/schemas/edgeToCloud/command_response.proto
)
endif()
if(FWE_FEATURE_LAST_KNOWN_STATE)
set(PROTO_FILES ${PROTO_FILES}
interfaces/protobuf/schemas/cloudToEdge/state_templates.proto
interfaces/protobuf/schemas/edgeToCloud/last_known_state_data.proto
)
endif()
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
add_library(fwe-proto OBJECT
${PROTO_SRCS}
${PROTO_HDRS}
)
target_include_directories(fwe-proto PUBLIC
${Protobuf_INCLUDE_DIRS}
)
# Protobuf does not support -Wall https://github.com/protocolbuffers/protobuf/issues/6781
set_source_files_properties(${PROTO_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-conversion -Wno-pedantic")
if(FWE_FEATURE_SOMEIP)
# CommonAPI code generation
set(CAPICXX_EXAMPLE_GENERATED_FILES
v1/commonapi/CommonTypes.hpp
v1/commonapi/CommonTypesSomeIPDeployment.cpp
v1/commonapi/CommonTypesSomeIPDeployment.hpp
v1/commonapi/ExampleSomeipInterface.hpp
v1/commonapi/ExampleSomeipInterfaceProxy.hpp
v1/commonapi/ExampleSomeipInterfaceProxyBase.hpp
v1/commonapi/ExampleSomeipInterfaceSomeIPDeployment.cpp
v1/commonapi/ExampleSomeipInterfaceSomeIPDeployment.hpp
v1/commonapi/ExampleSomeipInterfaceSomeIPProxy.cpp
v1/commonapi/ExampleSomeipInterfaceSomeIPProxy.hpp
v1/commonapi/ExampleSomeipInterfaceSomeIPStubAdapter.cpp
v1/commonapi/ExampleSomeipInterfaceSomeIPStubAdapter.hpp
v1/commonapi/ExampleSomeipInterfaceStub.hpp
v1/commonapi/ExampleSomeipInterfaceStubDefault.hpp
)
capicxx_generate_someip(
interfaces/someip/fidl/ExampleSomeipInterface.fidl
interfaces/someip/fidl/ExampleSomeipInterface.fdepl
"${CAPICXX_EXAMPLE_GENERATED_FILES}"
)
set(CAPICXX_DEVICE_SHADOW_GENERATED_FILES
v1/commonapi/DeviceShadowOverSomeipInterface.hpp
v1/commonapi/DeviceShadowOverSomeipInterfaceProxy.hpp
v1/commonapi/DeviceShadowOverSomeipInterfaceProxyBase.hpp
v1/commonapi/DeviceShadowOverSomeipInterfaceSomeIPDeployment.cpp
v1/commonapi/DeviceShadowOverSomeipInterfaceSomeIPDeployment.hpp
v1/commonapi/DeviceShadowOverSomeipInterfaceSomeIPProxy.cpp
v1/commonapi/DeviceShadowOverSomeipInterfaceSomeIPProxy.hpp
v1/commonapi/DeviceShadowOverSomeipInterfaceSomeIPStubAdapter.cpp
v1/commonapi/DeviceShadowOverSomeipInterfaceSomeIPStubAdapter.hpp
v1/commonapi/DeviceShadowOverSomeipInterfaceStub.hpp
v1/commonapi/DeviceShadowOverSomeipInterfaceStubDefault.hpp
)
capicxx_generate_someip(
interfaces/someip/fidl/DeviceShadowOverSomeipInterface.fidl
interfaces/someip/fidl/DeviceShadowOverSomeipInterface.fdepl
"${CAPICXX_DEVICE_SHADOW_GENERATED_FILES}"
)
endif()
set(HEADER_FILES
src/Assert.h
src/AwsBootstrap.h
src/AwsIotConnectivityModule.h
src/AwsIotReceiver.h
src/AwsIotSender.h
src/AwsSDKMemoryManager.h
src/CacheAndPersist.h
src/CANDataConsumer.h
src/CANDataSource.h
src/CANDataTypes.h
src/CANDecoder.h
src/CANInterfaceIDTranslator.h
src/CheckinSender.h
src/Clock.h
src/ClockHandler.h
src/CollectionInspectionAPITypes.h
src/CollectionInspectionEngine.h
src/CollectionInspectionWorkerThread.h
src/CollectionSchemeIngestion.h
src/CollectionSchemeIngestionList.h
src/CollectionSchemeManager.h
src/ConsoleLogger.h
src/CPUUsageInfo.h
src/DataFetchManagerAPITypes.h
src/DataFetchManager.h
src/DataSenderManager.h
src/DataSenderManagerWorkerThread.h
src/DataSenderProtoWriter.h
src/DataSenderTypes.h
src/DecoderManifestIngestion.h
src/EnumUtility.h
src/EventTypes.h
src/ExternalCANDataSource.h
src/ICollectionScheme.h
src/ICollectionSchemeList.h
src/IConnectionTypes.h
src/IConnectivityModule.h
src/IDecoderDictionary.h
src/IDecoderManifest.h
src/ILogger.h
src/IoTFleetWiseConfig.h
src/IoTFleetWiseEngine.h
src/IoTFleetWiseVersion.h
src/IReceiver.h
src/ISender.h
src/ISOTPOverCANOptions.h
src/ISOTPOverCANReceiver.h
src/ISOTPOverCANSender.h
src/ISOTPOverCANSenderReceiver.h
src/Listener.h
src/QueueTypes.h
src/LoggingModule.h
src/LogLevel.h
src/MemoryUsageInfo.h
src/MessageTypes.h
src/MqttClientWrapper.h
src/NamedSignalDataSource.h
src/OBDDataDecoder.h
src/OBDDataTypes.h
src/OBDOverCANECU.h
src/OBDOverCANModule.h
src/PayloadManager.h
src/QueueTypes.h
src/RawDataManager.h
src/RemoteProfiler.h
src/RetryThread.h
src/Schema.h
src/SchemaListener.h
src/Signal.h
src/SignalTypes.h
src/StreambufBuilder.h
src/TelemetryDataSender.h
src/Thread.h
src/Timer.h
src/TimeTypes.h
src/TraceModule.h
src/TopicConfig.h
src/VehicleDataSourceTypes.h
)
# Source files
set(SRC_FILES
src/AwsBootstrap.cpp
src/AwsIotReceiver.cpp
src/AwsIotSender.cpp
src/AwsIotConnectivityModule.cpp
src/AwsSDKMemoryManager.cpp
src/CacheAndPersist.cpp
src/CANDataConsumer.cpp
src/CANDataSource.cpp
src/CANDecoder.cpp
src/CheckinSender.cpp
src/ClockHandler.cpp
src/CollectionInspectionEngine.cpp
src/CollectionInspectionWorkerThread.cpp
src/CollectionSchemeIngestion.cpp
src/CollectionSchemeIngestionList.cpp
src/CollectionSchemeManager.cpp
src/ConsoleLogger.cpp
src/CPUUsageInfo.cpp
src/DataSenderManager.cpp
src/DataSenderManagerWorkerThread.cpp
src/DataSenderProtoWriter.cpp
src/DecoderDictionaryExtractor.cpp
src/DecoderManifestIngestion.cpp
src/ExternalCANDataSource.cpp
src/InspectionMatrixExtractor.cpp
src/IoTFleetWiseConfig.cpp
src/IoTFleetWiseEngine.cpp
src/ISOTPOverCANReceiver.cpp
src/ISOTPOverCANSender.cpp
src/ISOTPOverCANSenderReceiver.cpp
src/LoggingModule.cpp
src/MemoryUsageInfo.cpp
src/NamedSignalDataSource.cpp
src/OBDDataDecoder.cpp
src/OBDOverCANECU.cpp
src/OBDOverCANModule.cpp
src/PayloadManager.cpp
src/Persistency.cpp
src/RawDataManager.cpp
src/RemoteProfiler.cpp
src/RetryThread.cpp
src/Schema.cpp
src/TelemetryDataSender.cpp
src/DataFetchManager.cpp
src/Thread.cpp
src/TraceModule.cpp
${CMAKE_CURRENT_BINARY_DIR}/IoTFleetWiseVersion.cpp
$<TARGET_OBJECTS:fwe-proto>
)
# Test files
set(TEST_FILES
test/unit/AwsIotConnectivityModuleTest.cpp
test/unit/CacheAndPersistTest.cpp
test/unit/CANDataSourceTest.cpp
test/unit/CANDecoderTest.cpp
test/unit/ClockHandlerTest.cpp
test/unit/CollectionInspectionEngineTest.cpp
test/unit/CollectionInspectionWorkerThreadTest.cpp
test/unit/CollectionSchemeManagerGtest.cpp
test/unit/CollectionSchemeManagerTest.cpp
test/unit/CPUUsageInfoTest.cpp
test/unit/DataSenderManagerTest.cpp
test/unit/DataSenderManagerWorkerThreadTest.cpp
test/unit/DataFetchManagerTest.cpp
test/unit/DataSenderProtoWriterTest.cpp
test/unit/DecoderDictionaryExtractorTest.cpp
test/unit/ExternalCANDataSourceTest.cpp
test/unit/InspectionMatrixExtractorTest.cpp
test/unit/IoTFleetWiseConfigTest.cpp
test/unit/IoTFleetWiseEngineTest.cpp
test/unit/ISOTPOverCANProtocolTest.cpp
test/unit/LoggingModuleTest.cpp
test/unit/MemoryUsageInfoTest.cpp
test/unit/NamedSignalDataSourceTest.cpp
test/unit/OBDDataDecoderTest.cpp
test/unit/OBDOverCANModuleTest.cpp
test/unit/PayloadManagerTest.cpp
test/unit/PersistencyTest.cpp
test/unit/RawDataManagerTest.cpp
test/unit/RemoteProfilerTest.cpp
test/unit/SchemaTest.cpp
test/unit/ThreadTest.cpp
test/unit/TimerTest.cpp
test/unit/TraceModuleTest.cpp
test/unit/WaitUntilTest.cpp
)
set(BENCHMARK_TEST_FILES
test/unit/ClockHandlerBenchmarkTest.cpp
)
# Optional files
if(FWE_FEATURE_IWAVE_GPS)
set(SRC_FILES ${SRC_FILES} src/IWaveGpsSource.cpp)
set(TEST_FILES ${TEST_FILES} test/unit/IWaveGpsSourceTest.cpp)
set(HEADER_FILES ${HEADER_FILES} src/IWaveGpsSource.h)
endif()
if(FWE_FEATURE_EXTERNAL_GPS)
set(SRC_FILES ${SRC_FILES} src/ExternalGpsSource.cpp)
set(TEST_FILES ${TEST_FILES} test/unit/ExternalGpsSourceTest.cpp)
set(HEADER_FILES ${HEADER_FILES} src/ExternalGpsSource.h)
endif()
if(FWE_FEATURE_AAOS_VHAL)
set(SRC_FILES ${SRC_FILES} src/AaosVhalSource.cpp)
set(TEST_FILES ${TEST_FILES} test/unit/AaosVhalSourceTest.cpp)
set(HEADER_FILES ${HEADER_FILES} src/AaosVhalSource.h)
endif()
if(FWE_FEATURE_GREENGRASSV2)
set(SRC_FILES ${SRC_FILES}
src/AwsGreengrassV2ConnectivityModule.cpp
src/AwsGreengrassV2Receiver.cpp
src/AwsGreengrassV2Sender.cpp
)
set(HEADER_FILES ${HEADER_FILES}
src/AwsGreengrassV2ConnectivityModule.h
src/AwsGreengrassV2Receiver.h
src/AwsGreengrassV2Sender.h
)
endif()
if(FWE_FEATURE_S3)
set(SRC_FILES ${SRC_FILES} src/Credentials.cpp)
set(TEST_FILES ${TEST_FILES} test/unit/CredentialsTest.cpp)
set(HEADER_FILES ${HEADER_FILES}
src/Credentials.h
src/TransferManagerWrapper.h
)
endif()
if(FWE_FEATURE_VISION_SYSTEM_DATA)
set(SRC_FILES ${SRC_FILES}
src/DataSenderIonWriter.cpp
src/S3Sender.cpp
src/VisionSystemDataSender.cpp
)
set(TEST_FILES ${TEST_FILES}
test/unit/DataSenderIonWriterTest.cpp
test/unit/S3SenderTest.cpp
)
set(HEADER_FILES ${HEADER_FILES}
src/DataSenderIonWriter.h
src/S3Sender.h
src/VisionSystemDataSender.h
)
endif()
if(FWE_FEATURE_ROS2)
set(SRC_FILES ${SRC_FILES} src/ROS2DataSource.cpp)
set(HEADER_FILES ${HEADER_FILES} src/ROS2DataSource.h)
endif()
if(FWE_FEATURE_SOMEIP)
set(SRC_FILES ${SRC_FILES}
src/DeviceShadowOverSomeip.cpp
src/SomeipCommandDispatcher.cpp
src/SomeipDataSource.cpp
src/SomeipToCanBridge.cpp
${CAPICXX_EXAMPLE_GENERATED_FILES}
${CAPICXX_DEVICE_SHADOW_GENERATED_FILES}
)
set(HEADER_FILES ${HEADER_FILES}
src/DeviceShadowOverSomeip.h
src/ExampleSomeipInterfaceWrapper.h
src/ISomeipInterfaceWrapper.h
src/SomeipCommandDispatcher.h
src/SomeipDataSource.h
src/SomeipToCanBridge.h
)
set(TEST_FILES ${TEST_FILES}
test/unit/DeviceShadowOverSomeipTest.cpp
test/unit/SomeipCommandDispatcherTest.cpp
test/unit/SomeipDataSourceTest.cpp
test/unit/SomeipToCanBridgeTest.cpp
)
endif()
if(FWE_FEATURE_REMOTE_COMMANDS)
set(SRC_FILES ${SRC_FILES}
src/ActuatorCommandManager.cpp
src/CanCommandDispatcher.cpp
src/CommandResponseDataSender.cpp
src/CommandSchema.cpp
)
set(HEADER_FILES ${HEADER_FILES}
src/ActuatorCommandManager.h
src/CanCommandDispatcher.h
src/CommandResponseDataSender.h
src/CommandSchema.h
src/CommandTypes.h
src/ICommandDispatcher.h
)
set(TEST_FILES ${TEST_FILES}
test/unit/ActuatorCommandManagerTest.cpp
test/unit/CanCommandDispatcherTest.cpp
test/unit/CommandSchemaTest.cpp
)
endif()
if(FWE_FEATURE_LAST_KNOWN_STATE)
set(SRC_FILES ${SRC_FILES}
src/LastKnownStateDataSender.cpp
src/LastKnownStateIngestion.cpp
src/LastKnownStateInspector.cpp
src/LastKnownStateSchema.cpp
src/LastKnownStateWorkerThread.cpp
)
set(HEADER_FILES ${HEADER_FILES}
src/LastKnownStateDataSender.h
src/LastKnownStateIngestion.h
src/LastKnownStateInspector.h
src/LastKnownStateSchema.h
src/LastKnownStateTypes.h
src/LastKnownStateWorkerThread.h
)
set(TEST_FILES ${TEST_FILES}
test/unit/LastKnownStateSchemaTest.cpp
test/unit/LastKnownStateWorkerThreadTest.cpp
test/unit/LastKnownStateInspectorTest.cpp
)
endif()
if(FWE_TEST_FAKETIME)
set(FAKETIME_TEST_FILES test/unit/FakeSystemTimeTest.cpp)
endif()
if(FWE_FEATURE_STORE_AND_FORWARD)
set(HEADER_FILES ${HEADER_FILES}
src/RateLimiter.h
src/StoreFileSystem.h
src/StoreLogger.h
src/StreamManager.h
src/StreamForwarder.h
src/DataSenderProtoReader.h
src/IoTJobsDataRequestHandler.h)
set(SRC_FILES ${SRC_FILES}
src/RateLimiter.cpp
src/StoreFileSystem.cpp
src/StoreLogger.cpp
src/StreamManager.cpp
src/StreamForwarder.cpp
src/DataSenderProtoReader.cpp
src/IoTJobsDataRequestHandler.cpp)
set(TEST_FILES ${TEST_FILES}
test/unit/RateLimiterTest.cpp
test/unit/StoreFileSystemTest.cpp
test/unit/StoreLoggerTest.cpp
test/unit/StreamManagerTest.cpp
test/unit/StreamForwarderTest.cpp
test/unit/DataSenderProtoReaderTest.cpp
test/unit/IoTJobsDataRequestHandlerTest.cpp)
endif()
if (FWE_FEATURE_UDS_DTC_EXAMPLE)
set(SRC_FILES ${SRC_FILES}
src/ExampleUDSInterface.cpp)
set(HEADER_FILES ${HEADER_FILES}
src/ExampleUDSInterface.h)
set(TEST_FILES ${TEST_FILES}
test/unit/ExampleUDSInterfaceTest.cpp)
endif()
if(FWE_FEATURE_UDS_DTC)
set(SRC_FILES ${SRC_FILES}
src/RemoteDiagnosticDataSource.cpp)
set(HEADER_FILES ${HEADER_FILES}
src/RemoteDiagnosticDataSource.h
src/IRemoteDiagnostics.h)
endif()
if(FWE_FEATURE_CUSTOM_FUNCTION_EXAMPLES)
set(SRC_FILES ${SRC_FILES}
src/CustomFunctionMath.cpp
src/CustomFunctionMultiRisingEdgeTrigger.cpp)
set(HEADER_FILES ${HEADER_FILES}
src/CustomFunctionMath.h
src/CustomFunctionMultiRisingEdgeTrigger.h)
set(TEST_FILES ${TEST_FILES}
test/unit/CustomFunctionMathTest.cpp
test/unit/CustomFunctionMultiRisingEdgeTriggerTest.cpp)
endif()
# Dependencies
set(REQUIRED_BOOST_COMPONENTS "thread;filesystem")
if(FWE_FEATURE_SOMEIP)
add_compile_options("-DBOOST_UUID_NO_SIMD") # For clang compatibility
set(REQUIRED_BOOST_COMPONENTS "${REQUIRED_BOOST_COMPONENTS};system;program_options")
endif()
find_package(Boost 1.71.0 REQUIRED COMPONENTS ${REQUIRED_BOOST_COMPONENTS})
find_path(JSONCPP_INCLUDE_DIR "json/json.h" PATH_SUFFIXES "jsoncpp")
find_library(JSONCPP_LIBRARY NAMES jsoncpp)
find_path(SNAPPY_INCLUDE_DIR "snappy.h")
find_library(SNAPPY_LIBRARY NAMES snappy)
# Extra libraries are required to statically link with the AWS SDK. These are not always found by CMake, hence:
# - When FWE_STATIC_LINK is ON and FWE_AWS_SDK_EXTRA_LIBS is ON, automatically find the standard libraries: libcurl, libssl, libcrypto, libz
# - When FWE_AWS_SDK_EXTRA_LIBS is a list of libs, use those
# - When FWE_AWS_SDK_EXTRA_LIBS is OFF, don't link any extra libs
if(FWE_AWS_SDK_EXTRA_LIBS STREQUAL "ON")
if(NOT FWE_STATIC_LINK)
set(FWE_AWS_SDK_EXTRA_LIBS "")
else()
set(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
find_library(CURL_LIBRARY NAMES curl)
find_library(OPENSSL_SSL_LIBRARY NAMES ssl)
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto)
find_package(ZLIB REQUIRED)
set(FWE_AWS_SDK_EXTRA_LIBS "${CURL_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ZLIB::ZLIB")
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
elseif(FWE_AWS_SDK_EXTRA_LIBS STREQUAL "OFF")
set(FWE_AWS_SDK_EXTRA_LIBS "")
endif()
separate_arguments(FWE_AWS_SDK_EXTRA_LIBS)
set(REQUIRED_AWS_SDK_COMPONENTS "core")
if(FWE_FEATURE_S3)
set(REQUIRED_AWS_SDK_COMPONENTS "transfer;s3-crt;${REQUIRED_AWS_SDK_COMPONENTS}")
endif()
set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS ${FWE_AWS_SDK_SHARED_LIBS})
# Note: this should only be called once
find_package(AWSSDK REQUIRED COMPONENTS ${REQUIRED_AWS_SDK_COMPONENTS})
set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS})
if(FWE_FEATURE_GREENGRASSV2)
find_package(GreengrassIpc-cpp REQUIRED)
endif()
if(FWE_FEATURE_SOMEIP)
find_package(vsomeip3 REQUIRED)
find_package(CommonAPI REQUIRED)
find_package(CommonAPI-SomeIP REQUIRED)
# For someipigen:
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG REQUIRED)
endif()
# Object lib used in output binary and unit tests
add_library(fwe OBJECT
${SRC_FILES}
)
# Include dirs
target_include_directories(fwe PUBLIC
${JSONCPP_INCLUDE_DIR}
${SNAPPY_INCLUDE_DIR}
${Protobuf_INCLUDE_DIRS}
$<$<BOOL:${FWE_FEATURE_SOMEIP}>:${VSOMEIP_INCLUDE_DIRS} ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_SOMEIP_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<$<BOOL:${FWE_FEATURE_STORE_AND_FORWARD}>:${STORE_LIBRARY_CPP_INCLUDE_DIR}>
)
# Link libraries
target_link_libraries(fwe
$<$<BOOL:${FWE_FEATURE_GREENGRASSV2}>:AWS::GreengrassIpc-cpp>
$<$<BOOL:${FWE_FEATURE_STORE_AND_FORWARD}>:${STORE_LIBRARY_CPP_STREAM}>
$<$<BOOL:${FWE_FEATURE_STORE_AND_FORWARD}>:${STORE_LIBRARY_CPP_KV}>
${AWSSDK_LINK_LIBRARIES}
${FWE_AWS_SDK_EXTRA_LIBS}
${SNAPPY_LIBRARY}
${JSONCPP_LIBRARY}
${Protobuf_LIBRARIES}
Boost::thread
Boost::filesystem
$<$<BOOL:${FWE_FEATURE_ROS2}>:fastcdr>
$<$<BOOL:${FWE_FEATURE_SOMEIP}>:CommonAPI-SomeIP>
$<$<BOOL:${FWE_FEATURE_SOMEIP}>:CommonAPI>
$<$<BOOL:${FWE_FEATURE_SOMEIP}>:${VSOMEIP_LIBRARIES}>
$<$<BOOL:${FWE_FEATURE_SOMEIP}>:Boost::system>
)
if(FWE_FEATURE_VISION_SYSTEM_DATA)
find_package(IonC)
target_link_libraries(fwe
$<$<BOOL:${FWE_STATIC_LINK}>:IonC::ionc_static>
$<$<BOOL:${FWE_STATIC_LINK}>:IonC::decNumber_static>
$<$<NOT:$<BOOL:${FWE_STATIC_LINK}>>:IonC::ionc>
$<$<NOT:$<BOOL:${FWE_STATIC_LINK}>>:IonC::decNumber>
)
endif()
if(FWE_FEATURE_ROS2)
ament_target_dependencies(fwe rclcpp)
endif()
# Executable or library output binary
if(FWE_BUILD_EXECUTABLE)
add_executable(aws-iot-fleetwise-edge
src/main.cpp
)
install(TARGETS aws-iot-fleetwise-edge
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
target_link_libraries(aws-iot-fleetwise-edge
-Xlinker
-Map=aws-iot-fleetwise-edge.map
)
elseif(FWE_BUILD_ANDROID_SHARED_LIBRARY)
add_library(aws-iot-fleetwise-edge SHARED
src/android_shared_library.cpp
)
target_link_libraries(aws-iot-fleetwise-edge
log
android
)
else()
add_library(aws-iot-fleetwise-edge
$<TARGET_OBJECTS:fwe>
)
set_target_properties(aws-iot-fleetwise-edge
PROPERTIES PUBLIC_HEADER "${HEADER_FILES};${PROTO_HDRS}"
)
install(TARGETS aws-iot-fleetwise-edge fwe fwe-proto
EXPORT AwsIotFweTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iotfleetwise"
)
install(EXPORT AwsIotFweTargets
FILE AwsIotFweTargets.cmake
NAMESPACE AwsIotFwe::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AwsIotFwe
)
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/AwsIotFweConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/AwsIotFweConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AwsIotFwe
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/AwsIotFweConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/AwsIotFweConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/AwsIotFweConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AwsIotFwe
)
endif()
target_link_libraries(aws-iot-fleetwise-edge
fwe
fwe-proto
)
set_target_properties(aws-iot-fleetwise-edge fwe fwe-proto
PROPERTIES POSITION_INDEPENDENT_CODE ON
)
# Unit tests
if(${BUILD_TESTING})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/unit/support/static-config-ok.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/unit/support/static-config-corrupt.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/unit/support/static-config-inline-creds.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
find_package(GTest REQUIRED)
find_library(GMOCK_LIB NAMES gmock)
find_package(benchmark REQUIRED)
# Google Test executable
add_executable(fwe-gtest
${TEST_FILES}
test/unit/support/main.cpp
)
target_include_directories(fwe-gtest PUBLIC
src
test/unit/support
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(fwe-gtest
fwe
fwe-proto
${GMOCK_LIB}
GTest::GTest
)
add_unit_test(fwe-gtest)
add_valgrind_test(fwe-gtest)
# Google Benchmark executable
add_executable(fwe-benchmark
${BENCHMARK_TEST_FILES}
)
target_include_directories(fwe-benchmark PUBLIC
src
test/unit/support
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(fwe-benchmark
fwe
fwe-proto
benchmark::benchmark
)
add_test(
NAME fwe-benchmark
COMMAND fwe-benchmark --benchmark_out=benchmark-report.txt --benchmark_out_format=console
)
if(FWE_TEST_FAKETIME)
# Faketime test executable
add_executable(fwe-faketime
${FAKETIME_TEST_FILES}
test/unit/support/main.cpp
)
target_include_directories(fwe-faketime PUBLIC
src
test/unit/support
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(fwe-faketime
fwe
fwe-proto
${GMOCK_LIB}
GTest::GTest
)
add_unit_test_with_faketime(fwe-faketime)
endif()
# TODO: Special case for ROS2DataSourceTest as it uses compile-time mocking
if(FWE_FEATURE_ROS2)
add_executable(ROS2DataSourceTest
test/unit/ROS2DataSourceTest.cpp
src/ROS2DataSource.cpp
src/RawDataManager.cpp
src/Thread.cpp
src/LoggingModule.cpp
src/ClockHandler.cpp
src/ConsoleLogger.cpp
src/IoTFleetWiseConfig.cpp
test/unit/support/main.cpp
)
target_include_directories(ROS2DataSourceTest PUBLIC
src
test/unit/support
${CMAKE_CURRENT_BINARY_DIR}
test/unit/support/ros2-mock-include
)
target_link_libraries(ROS2DataSourceTest
${JSONCPP_LIBRARY}
fastcdr
${GMOCK_LIB}
GTest::GTest
)
add_unit_test(ROS2DataSourceTest)
add_valgrind_test(ROS2DataSourceTest)
endif()
endif()
# Tools
if(FWE_BUILD_TOOLS)
if(FWE_FEATURE_SOMEIP)
include(tools/can-to-someip/can-to-someip.cmake)
include(tools/someipigen/someipigen.cmake)
include(tools/someip_device_shadow_editor/someip_device_shadow_editor.cmake)
endif()
endif()