forked from COVESA/vsomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
743 lines (614 loc) · 27.5 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
# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required (VERSION 3.10)
project (vsomeip)
set (VSOMEIP_NAME vsomeip3)
set (VSOMEIP_COMPAT_NAME vsomeip)
set (VSOMEIP_MAJOR_VERSION 3)
set (VSOMEIP_MINOR_VERSION 3)
set (VSOMEIP_PATCH_VERSION 8)
set (VSOMEIP_HOTFIX_VERSION 0)
set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION})
set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentation/doxygen.in
set (CMAKE_VERBOSE_MAKEFILE off)
if (NOT GTEST_ROOT)
if (DEFINED ENV{GTEST_ROOT})
set(GTEST_ROOT $ENV{GTEST_ROOT})
else()
set(GTEST_ROOT "n/a" CACHE STRING "Path to root folder of googletest. Must be set for building the tests.")
endif()
endif()
###################################################################################################
# see http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
###################################################################################################
# Offer the user the choice of overriding the installation directories
set (INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set (INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set (INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
if (WIN32 AND NOT CYGWIN)
set (DEF_INSTALL_CMAKE_DIR CMake)
else ()
set (DEF_INSTALL_CMAKE_DIR lib/cmake/${VSOMEIP_NAME})
endif ()
set (INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
# Make relative paths absolute (needed later on)
foreach (p LIB BIN INCLUDE CMAKE)
set (var INSTALL_${p}_DIR)
if (NOT IS_ABSOLUTE "${${var}}")
set (ABSOLUTE_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") # Add all targets to the build-tree export set
endif ()
endforeach ()
###################################################################################################
# Set a default build type if none was specified
set(default_build_type "RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# OS
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(DL_LIBRARY "dl")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# This is only relevant for GCC and causes warnings on Clang
set(EXPORTSYMBOLS "-Wl,-export-dynamic -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap.gcc")
set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -pie -Wl,-z,relro,-z,now")
endif()
set(NO_DEPRECATED "")
set(OPTIMIZE "")
set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -D_GLIBCXX_USE_NANOSLEEP -pthread -O -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wpedantic -Werror -fPIE")
# force all use of std::mutex and std::recursive_mutex to use runtime init
# instead of static initialization so mutexes can be hooked to enable PI as needed
add_definitions(-D_GTHREAD_USE_MUTEX_INIT_FUNC -D_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(DL_LIBRARY "")
set(EXPORTSYMBOLS "")
set(NO_DEPRECATED "-Wno-deprecated")
set(OPTIMIZE "")
set(OS_CXX_FLAGS "-pthread")
endif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
############################################My lib link flags####################################
# Options
################################################################################
# DLT
if (DISABLE_DLT)
set (VSOMEIP_ENABLE_DLT 0)
else ()
set (VSOMEIP_ENABLE_DLT 1)
endif ()
# Signal handling
if (ENABLE_SIGNAL_HANDLING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_SIGNAL_HANDLING")
endif ()
if (NOT MSVC)
# Sanitizers
if (ENABLE_UNDEFINED_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif ()
if (ENABLE_THREAD_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
endif ()
if (ENABLE_LEAK_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
endif ()
if (ENABLE_ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif ()
if (ENABLE_PROFILING)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
endif ()
endif (NOT MSVC)
# Compatibility
if (ENABLE_COMPAT)
set (VSOMEIP_ENABLE_COMPAT 1)
else ()
set (VSOMEIP_ENABLE_COMPAT 0)
endif ()
# Multiple routing managers
if (ENABLE_MULTIPLE_ROUTING_MANAGERS)
set (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS 1)
else ()
set (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS 0)
endif ()
# Security / Policy handling
if (DISABLE_SECURITY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_DISABLE_SECURITY")
endif ()
# Suppress deprecation warnings for vSomeIP interfaces
add_definitions(-DVSOMEIP_INTERNAL_SUPPRESS_DEPRECATED)
################################################################################
# Dependencies
################################################################################
# Threads
find_package(Threads REQUIRED)
# Boost
find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED )
include_directories(SYSTEM ${Boost_INCLUDE_DIR} )
if(Boost_FOUND)
if(Boost_LIBRARY_DIR)
MESSAGE( STATUS "Boost_LIBRARY_DIR not empty using it: ${Boost_LIBRARY_DIR}" )
else()
if(BOOST_LIBRARYDIR)
MESSAGE( STATUS "Boost_LIBRARY_DIR empty but BOOST_LIBRARYDIR is set setting Boost_LIBRARY_DIR to: ${BOOST_LIBRARYDIR}" )
set(Boost_LIBRARY_DIR ${BOOST_LIBRARYDIR})
endif()
endif()
else()
MESSAGE( STATUS "Boost was not found!")
endif()
# cmake 3.15 introduced a new variable and a new format for the old one
if (DEFINED Boost_VERSION_MACRO)
set(VSOMEIP_BOOST_VERSION ${Boost_VERSION_MACRO})
else()
set(VSOMEIP_BOOST_VERSION ${Boost_VERSION})
endif()
message( STATUS "Using boost version: ${VSOMEIP_BOOST_VERSION}" )
if (${VSOMEIP_BOOST_VERSION} LESS 106600)
include_directories(SYSTEM
implementation/helper
)
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_BOOST_VERSION=${VSOMEIP_BOOST_VERSION}")
find_package(PkgConfig)
# DLT
if(VSOMEIP_ENABLE_DLT EQUAL 1)
pkg_check_modules(DLT "automotive-dlt >= 2.11")
if(DLT_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_DLT")
endif(DLT_FOUND)
endif()
# SystemD
pkg_check_modules(SystemD "libsystemd")
if(NOT SystemD_FOUND)
MESSAGE( STATUS "Systemd was not found, watchdog disabled!")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITHOUT_SYSTEMD")
endif(NOT SystemD_FOUND)
# Multiple routing managers
if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS")
endif ()
################################################################################
# Directories
################################################################################
include_directories(
interface
)
include_directories(SYSTEM
${DLT_INCLUDE_DIRS}
)
link_directories(
${DLT_LIBDIR}
)
if (${VSOMEIP_HOTFIX_VERSION} EQUAL 0)
add_definitions(-DVSOMEIP_VERSION="${VSOMEIP_VERSION}")
else()
add_definitions(-DVSOMEIP_VERSION="${VSOMEIP_VERSION}.${VSOMEIP_HOTFIX_VERSION}")
endif()
if (MSVC)
message("using MSVC Compiler")
# add_definitions(-DVSOMEIP_DLL_COMPILATION) now it is controlled per target
SET(BOOST_WINDOWS_VERSION "0x600" CACHE STRING "Set the same Version as the Version with which Boost was built, otherwise there will be errors. (normaly 0x600 is for Windows 7 and 0x501 is for Windows XP)")
# Disable warning C4250 since it warns that the compiler is correctly following the C++ Standard. It's a "We-Are-Doing-Things-By-The-Book" notice, not a real warning.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_WIN32_WINNT=${BOOST_WINDOWS_VERSION} -DWIN32 -DBOOST_ASIO_DISABLE_IOCP /EHsc /std:c++14 /wd4250")
set(USE_RT "")
link_directories(${Boost_LIBRARY_DIR_DEBUG})
ADD_DEFINITIONS( -DBOOST_ALL_DYN_LINK )
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OS_CXX_FLAGS} -g ${OPTIMIZE} -std=c++14 ${NO_DEPRECATED} ${EXPORTSYMBOLS}")
set(USE_RT "rt")
endif()
################################################################################
# Configuration library
################################################################################
file(GLOB ${VSOMEIP_NAME}-cfg_SRC
"implementation/configuration/src/*.cpp"
)
list(SORT ${VSOMEIP_NAME}-cfg_SRC)
if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 0)
add_library(${VSOMEIP_NAME}-cfg SHARED ${${VSOMEIP_NAME}-cfg_SRC})
set_target_properties (${VSOMEIP_NAME}-cfg PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION})
if (MSVC)
set_target_properties(${VSOMEIP_NAME}-cfg PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN")
endif()
target_link_libraries(${VSOMEIP_NAME}-cfg ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES})
endif ()
################################################################################
# Base library
################################################################################
file(GLOB ${VSOMEIP_NAME}_SRC
"implementation/endpoints/src/*.cpp"
"implementation/logger/src/*.cpp"
"implementation/tracing/src/*.cpp"
"implementation/message/src/*.cpp"
"implementation/plugin/src/*.cpp"
"implementation/protocol/src/*.cpp"
"implementation/routing/src/*.cpp"
"implementation/runtime/src/*.cpp"
"implementation/security/src/*.cpp"
"implementation/utility/src/*.cpp"
)
if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 1)
list(APPEND ${VSOMEIP_NAME}_SRC "implementation/configuration/src/configuration_impl.cpp")
endif()
if (WIN32)
list(FILTER ${VSOMEIP_NAME}_SRC EXCLUDE REGEX ".*uds.*")
endif()
list(SORT ${VSOMEIP_NAME}_SRC)
add_library(${VSOMEIP_NAME} SHARED ${${VSOMEIP_NAME}_SRC})
set_target_properties (${VSOMEIP_NAME} PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION})
if (MSVC)
set_target_properties(${VSOMEIP_NAME} PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION")
else ()
set_target_properties(${VSOMEIP_NAME} PROPERTIES LINK_FLAGS "-Wl,-wrap,socket -Wl,-wrap,accept -Wl,-wrap,open")
endif ()
target_include_directories(${VSOMEIP_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/interface>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>)
# PRIVATE means the listed libraries won't be included in the "link interface",
# meaning the exported ${VSOMEIP_NAME}Targets.cmake targets won't try to link against
# them (which shouldn't be required). ${Boost_LIBRARIES} includes absolute
# build host paths as of writing, which also makes this important as it breaks
# the build.
target_link_libraries(${VSOMEIP_NAME} PRIVATE ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${DLT_LIBRARIES} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
if(NOT WIN32)
target_link_options(${VSOMEIP_NAME} PRIVATE "LINKER:-as-needed")
endif()
################################################################################
# Service Discovery library
################################################################################
file(GLOB ${VSOMEIP_NAME}-sd_SRC
"implementation/service_discovery/src/*.cpp"
)
list(SORT ${VSOMEIP_NAME}-sd_SRC)
add_library(${VSOMEIP_NAME}-sd SHARED ${${VSOMEIP_NAME}-sd_SRC})
set_target_properties (${VSOMEIP_NAME}-sd PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION})
if (MSVC)
set_target_properties(${VSOMEIP_NAME}-sd PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN")
endif ()
target_link_libraries(${VSOMEIP_NAME}-sd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
################################################################################
# E2E library
################################################################################
file(GLOB_RECURSE ${VSOMEIP_NAME}-e2e_SRC
"implementation/e2e_protection/src/*.cpp"
)
list(SORT ${VSOMEIP_NAME}-e2e_SRC)
add_library(${VSOMEIP_NAME}-e2e SHARED ${${VSOMEIP_NAME}-e2e_SRC})
set_target_properties (${VSOMEIP_NAME}-e2e PROPERTIES VERSION ${VSOMEIP_VERSION} SOVERSION ${VSOMEIP_MAJOR_VERSION})
if (MSVC)
set_target_properties(${VSOMEIP_NAME}-e2e PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN")
endif ()
target_link_libraries(${VSOMEIP_NAME}-e2e ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES})
################################################################################
# Compatibility library
################################################################################
if (VSOMEIP_ENABLE_COMPAT EQUAL 1)
set (VSOMEIP_COMPAT_MAJOR_VERSION 2)
set (VSOMEIP_COMPAT_VERSION ${VSOMEIP_COMPAT_MAJOR_VERSION}.99.99)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_COMPAT")
file(GLOB_RECURSE ${VSOMEIP_COMPAT_NAME}_SRC
"implementation/compat/logging/src/*.cpp"
"implementation/compat/message/src/*.cpp"
"implementation/compat/runtime/src/*.cpp"
)
list(SORT ${VSOMEIP_COMPAT_NAME}_SRC)
add_library(${VSOMEIP_COMPAT_NAME} SHARED ${${VSOMEIP_COMPAT_NAME}_SRC})
set_target_properties (${VSOMEIP_COMPAT_NAME} PROPERTIES VERSION ${VSOMEIP_COMPAT_VERSION} SOVERSION ${VSOMEIP_COMPAT_MAJOR_VERSION})
if (MSVC)
set_target_properties(${VSOMEIP_COMPAT_NAME} PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION_PLUGIN")
endif ()
target_include_directories(
${VSOMEIP_COMPAT_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/interface/compat>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> # for generated files in build mode
$<INSTALL_INTERFACE:include/compat> # for clients in install mode
)
target_link_libraries(${VSOMEIP_COMPAT_NAME} PRIVATE ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES})
endif ()
################################################################################
# Configuration files
################################################################################
set(EXAMPLE_CONFIG_FILES
"config/vsomeip.json"
"config/vsomeip-local.json"
"config/vsomeip-tcp-client.json"
"config/vsomeip-tcp-service.json"
"config/vsomeip-udp-client.json"
"config/vsomeip-udp-service.json"
)
################################################################################
# Configuration parameters
################################################################################
set (VSOMEIP_BASE_PATH "/tmp")
if (BASE_PATH)
set (VSOMEIP_BASE_PATH ${BASE_PATH})
endif ()
set (VSOMEIP_DIAGNOSIS_ADDRESS "0x01")
if (DIAGNOSIS_ADDRESS)
set (VSOMEIP_DIAGNOSIS_ADDRESS ${DIAGNOSIS_ADDRESS})
endif ()
set (VSOMEIP_UNICAST_ADDRESS "127.0.0.1")
if (UNICAST_ADDRESS)
set (VSOMEIP_UNICAST_ADDRESS ${UNICAST_ADDRESS})
endif ()
set (VSOMEIP_ROUTING_READY_MESSAGE "SOME/IP routing ready.")
if (ROUTING_READY_MESSAGE)
set (VSOMEIP_ROUTING_READY_MESSAGE ${ROUTING_READY_MESSAGE})
endif ()
set(DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" CACHE PATH "Default configuration folder")
message(STATUS "Default configuration folder: ${DEFAULT_CONFIGURATION_FOLDER}")
set(DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json" CACHE FILEPATH "Default configuration file")
message(STATUS "Default configuration file: ${DEFAULT_CONFIGURATION_FILE}")
message("Predefined base path: ${VSOMEIP_BASE_PATH}")
message("Predefined unicast address: ${VSOMEIP_UNICAST_ADDRESS}")
message("Predefined diagnosis address: ${VSOMEIP_DIAGNOSIS_ADDRESS}")
################################################################################
# Installation
################################################################################
set(INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/interface/vsomeip")
file (GLOB_RECURSE vsomeip_INCLUDE RELATIVE ${INCLUDE_PATH} "interface/*.h*" )
list (SORT vsomeip_INCLUDE)
foreach ( file ${vsomeip_INCLUDE} )
get_filename_component( dir ${file} DIRECTORY )
install( FILES "${INCLUDE_PATH}/${file}" DESTINATION "${INSTALL_INCLUDE_DIR}/vsomeip/${dir}" COMPONENT dev)
endforeach()
install (
TARGETS ${VSOMEIP_NAME}
# IMPORTANT: Add the vsomeip library to the "export-set"
EXPORT ${VSOMEIP_NAME}Targets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
COMPONENT dev
)
install (
TARGETS ${VSOMEIP_NAME}-e2e
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
)
if (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS EQUAL 0)
install (
TARGETS ${VSOMEIP_NAME}-cfg
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
)
endif ()
install (
TARGETS ${VSOMEIP_NAME}-sd
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
)
if (VSOMEIP_ENABLE_COMPAT EQUAL 1)
install (
TARGETS ${VSOMEIP_COMPAT_NAME}
EXPORT vsomeipTargets
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
)
export (TARGETS ${VSOMEIP_COMPAT_NAME} FILE "${PROJECT_BINARY_DIR}/vsomeipTargets.cmake")
export (PACKAGE ${VSOMEIP_COMPAT_NAME})
configure_file (vsomeipConfig.cmake.in "${PROJECT_BINARY_DIR}/vsomeipConfig.cmake" @ONLY)
configure_file (vsomeipConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/vsomeipConfigVersion.cmake" @ONLY)
set (COMPAT_INSTALL_CMAKE_DIR "lib/cmake/${VSOMEIP_COMPAT_NAME}")
install (
EXPORT vsomeipTargets
DESTINATION "${COMPAT_INSTALL_CMAKE_DIR}"
COMPONENT dev
)
install (
FILES
"${PROJECT_BINARY_DIR}/vsomeipConfig.cmake"
"${PROJECT_BINARY_DIR}/vsomeipConfigVersion.cmake"
DESTINATION "${COMPAT_INSTALL_CMAKE_DIR}"
COMPONENT dev
)
configure_file(vsomeip.pc.in ${PROJECT_BINARY_DIR}/vsomeip.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/vsomeip.pc DESTINATION lib/pkgconfig)
endif ()
install (
FILES ${EXAMPLE_CONFIG_FILES} DESTINATION etc/vsomeip COMPONENT config
)
# Add all targets to the build-tree export set
export (TARGETS ${VSOMEIP_NAME} FILE "${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}Targets.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export (PACKAGE ${VSOMEIP_NAME})
# Create the ${VSOMEIP_NAME}Config.cmake and ${VSOMEIP_NAME}ConfigVersion files
configure_file (${VSOMEIP_NAME}Config.cmake.in "${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}Config.cmake" @ONLY)
configure_file (${VSOMEIP_NAME}ConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}ConfigVersion.cmake" @ONLY)
# configure internal.hpp for correct version number
configure_file (
"${PROJECT_SOURCE_DIR}/implementation/configuration/include/internal.hpp.in"
"${PROJECT_SOURCE_DIR}/implementation/configuration/include/internal.hpp"
)
# Install the ${VSOMEIP_NAME}Config.cmake and ${VSOMEIP_NAME}ConfigVersion.cmake
install (
FILES
"${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}ConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev
)
# Install the export set for use with the install-tree
install (
EXPORT ${VSOMEIP_NAME}Targets
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev
)
##############################################################################
# build documentation
##############################################################################
add_custom_target(doc)
find_package(Doxygen)
if (NOT DOXYGEN_FOUND)
message(WARNING "Doxygen is not installed. Documentation can not be built.")
else()
# set configuration variables for doxygen.in
set(PROJECT "vsomeip")
set(DOCDIR documentation)
set(SRCDIR .)
set(GENERATE_HTML YES)
set(GENERATE_HTMLHELP NO)
set(GENERATE_CHI NO)
set(GENERATE_LATEX NO)
set(GENERATE_PDF NO)
set(GENERATE_RTF NO)
set(GENERATE_MAN NO)
set(GENERATE_XML NO)
set(HAVE_DOT YES)
if(HAVE_DOT)
# Note: the @DOT_PATH@ variable won't be used in doxygen.in as doxygen
# somehow manages to strip the last slash from the path and therfore no
# graphs are generated. Therefore dot should be available in your $PATH
FIND_PROGRAM(DOT_PATH dot)
if ("${DOT_PATH}" STREQUAL "DOT_PATH-NOTFOUND")
message(WARNING "dot (graphviz) is not installed. Graphs in documentation can't be generated.")
else()
message("dot found")
endif()
endif()
configure_file(documentation/doxygen.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doxygen-doc
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
add_dependencies(doc doxygen-doc)
endif()
find_program(ASCIIDOC_PATH asciidoc)
find_program(SOURCE_HIGHLIGHT_PATH source-highlight)
if ("${ASCIIDOC_PATH}" STREQUAL "ASCIIDOC_PATH-NOTFOUND")
message(WARNING "asciidoc is not installed. Readme can not be built.")
elseif("${SOURCE_HIGHLIGHT_PATH}" STREQUAL "SOURCE_HIGHLIGHT_PATH-NOTFOUND")
message(WARNING "source-highlight is not installed. Readme can not be built.")
else()
message("asciidoc found")
message("source-highlight found")
add_custom_command(TARGET doc
POST_BUILD
COMMAND asciidoc
-a version=${VSOMEIP_VERSION}
-b html
-o documentation/vsomeipUserGuide.html
${PROJECT_SOURCE_DIR}/documentation/vsomeipUserGuide)
endif()
##############################################################################
# create pkg-config file
if(NOT WIN32)
configure_file(${VSOMEIP_NAME}.pc.in ${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/${VSOMEIP_NAME}.pc DESTINATION lib/pkgconfig)
endif()
##############################################################################
# build routing manager daemon (Non-Windows only)
if (NOT MSVC)
add_subdirectory( examples/routingmanagerd )
endif()
# build tools
add_custom_target( tools )
add_subdirectory( tools )
# build examples
add_custom_target( examples )
add_subdirectory( examples EXCLUDE_FROM_ALL )
##############################################################################
# Test section
##############################################################################
##############################################################################
# google benchmark
find_package(benchmark)
##############################################################################
# google test
# check for set environment variable
if(${GTEST_ROOT} STREQUAL "n/a")
message(STATUS "GTEST_ROOT is not defined. For building the tests the variable
GTEST_ROOT has to be defined. Tests can not be built.")
# early exit
return() # test can not be build -> make commands build_tests and check are not available
else()
message(STATUS "GTEST_ROOT is set. gtest root path set to ${GTEST_ROOT}")
endif()
# build google test as static library (always) -> therefore deactivate BUILD_SHARED_LIBS in case it is active
set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0)
if ("${BUILD_SHARED_LIBS}" STREQUAL "ON")
set(BUILD_SHARED_LIBS OFF)
set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 1)
endif()
add_subdirectory(${GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL)
if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1")
set(BUILD_SHARED_LIBS ON)
set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0)
endif()
##############################################################################
# build tests
enable_testing()
SET(TESTS_BAT "OFF" CACHE BOOL
"Controls whether only BAT tests should be build or not")
SET(TEST_SYMLINK_CONFIG_FILES "OFF" CACHE BOOL
"Controls if the json and scripts needed needed to run the tests are copied or symlinked into the build directroy (ignored on Windows)")
SET(TEST_SYMLINK_CONFIG_FILES_RELATIVE "OFF" CACHE BOOL
"Controls if the json and scripts needed needed to run the tests are symlinked relatively into the build directroy (ignored on Windows)")
SET(TEST_IP_DEFAULT_VALUE "XXX.XXX.XXX.XXX")
SET(TEST_IP_MASTER "${TEST_IP_DEFAULT_VALUE}" CACHE STRING
"The IP address of the interface which will act as test master")
SET(TEST_IP_SLAVE "${TEST_IP_DEFAULT_VALUE}" CACHE STRING
"The IP address of the interface which will act as test slave")
if((${TEST_IP_MASTER} STREQUAL ${TEST_IP_DEFAULT_VALUE}) OR
(${TEST_IP_SLAVE} STREQUAL ${TEST_IP_DEFAULT_VALUE}))
message(WARNING "TEST_IP_MASTER and/or TEST_IP_SLAVE isn't set. "
"Remote tests cannot be run. "
"To enable, please specify for example "
"-DTEST_IP_MASTER=10.0.3.1 -DTEST_IP_SLAVE=10.0.3.2")
endif()
SET(TEST_IP_SLAVE_SECOND "${TEST_IP_DEFAULT_VALUE}" CACHE STRING
"The second IP address of the interface which will act as test slave")
set(TEST_SECOND_ADDRESS "OFF" CACHE BOOL
"Controls whether second address tests should run or not")
if(${TEST_IP_SLAVE_SECOND} STREQUAL ${TEST_IP_DEFAULT_VALUE})
message(WARNING "TEST_IP_SLAVE_SECOND isn't set. "
"Test with more than one IP address on same interface is not enabled."
"Please specify them via for example "
"-TEST_IP_SLAVE_SECOND=10.0.3.126")
else()
set(TEST_SECOND_ADDRESS "ON")
endif()
set(TEST_E2E_PROFILE_04 "ON")
SET(TEST_UID_DEFAULT_VALUE "123456789")
SET(TEST_UID "${TEST_UID_DEFAULT_VALUE}" CACHE STRING
"The User ID of the user running the test: Needed for security")
SET(TEST_GID_DEFAULT_VALUE "123456789")
SET(TEST_GID "${TEST_GID_DEFAULT_VALUE}" CACHE STRING
"The Group ID of the user running the test: Needed for security")
SET(TEST_SECURITY "ON" CACHE BOOL
"Controls whether security tests should run or not")
if((${TEST_UID} STREQUAL ${TEST_UID_DEFAULT_VALUE}) OR
(${TEST_GID} STREQUAL ${TEST_GID_DEFAULT_VALUE}) OR
DISABLE_SECURITY)
message(WARNING "TEST_UID and/or TEST_GID isn't set. "
"Security Tests are not runnable "
"Please specify them for example "
"-DTEST_UID=1000 -DTEST_GID=1000")
SET(TEST_SECURITY "OFF")
endif()
add_custom_target(build_tests)
set(CMAKE_CTEST_COMMAND ctest -V)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_dependencies(check build_tests)
add_custom_target(build_network_tests)
add_dependencies(build_network_tests ${VSOMEIP_NAME})
add_dependencies(build_network_tests ${VSOMEIP_NAME}-e2e)
add_dependencies(build_network_tests ${VSOMEIP_NAME}-sd)
add_dependencies(build_tests build_network_tests)
add_custom_target(build_unit_tests)
add_dependencies(build_unit_tests ${VSOMEIP_NAME})
add_dependencies(build_unit_tests ${VSOMEIP_NAME}-sd)
add_dependencies(build_tests build_unit_tests)
add_custom_target(build_benchmark_tests)
add_dependencies(build_benchmark_tests ${VSOMEIP_NAME})
add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}-sd)
add_dependencies(build_tests build_benchmark_tests)
##############################################################################
# add test directory
add_subdirectory( test EXCLUDE_FROM_ALL )