diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 000000000..0d42c3733 --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,388 @@ +# ---------------------------------- +# Options affecting listfile parsing +# ---------------------------------- +with section("parse"): + # Specify structure for custom cmake functions + + _target_sources_files = { + "kwargs": { + "FILE_SET": { + "pargs": {"flags": ["HEADERS"]}, + "kwargs": { + "TYPE": "1", + "BASE_DIRS": "+", + "FILES": "+", + }, + } + }, + } + + _install_type_args = { + "pargs": { + "nargs": "+", + "flags": ["RUNTIME", "ARCHIVE", "LIBRARY", "OBJECTS"], + }, + "kwargs": { + "DESTINATION": {"pargs": {"nargs": 1}}, + "EXPORT": {"pargs": {"nargs": 1}}, + "NAMESPACE": {"pargs": {"nargs": 1}}, + "COMPONENT": {"pargs": {"nargs": 1}}, + "EXCLUDE_FROM_ALL": {"pargs": {"nargs": 0}}, + "PERMISSIONS": { + "pargs": { + "nargs": "+", + "flags": [ + "OWNER_READ", + "OWNER_WRITE", + "OWNER_EXECUTE", + "GROUP_READ", + "GROUP_EXECUTE", + "WORLD_READ", + "WORLD_EXECUTE", + ], + } + }, + }, + } + _files_install_type_args = _install_type_args.copy() + _files_install_type_args["kwargs"]["TYPE"] = { + "pargs": {"nargs": 1, "flags": ["SYSCONF", "BIN"]} + } + _directory_install_type_args = _install_type_args.copy() + _directory_install_type_args["kwargs"]["EXCLUDE PATTERN"] = {"pargs": {"nargs": 1}} + _directory_install_type_args["kwargs"]["PATTERN"] = {"pargs": {"nargs": 1}} + + additional_commands = { + "file": { + "kwargs": { + "GENERATE": { + "kwargs": { + "OUTPUT": 1, + "CONTENT": 1, + "NEWLINE_STYLE": { + "pargs": { + "nargs": 1, + }, + }, + } + } + } + }, + "add_library": { + "pargs": { + "nargs": "+", + "flags": ["SHARED", "STATIC", "EXCLUDE_FROM_ALL"], + } + }, + "target_sources": { + "pargs": { + "nargs", + 1, + }, + "kwargs": { + "PRIVATE": _target_sources_files, + "PUBLIC": _target_sources_files, + }, + }, + "target_link_libraries": { + "pargs": "*", + "kwargs": {"PUBLIC": "*", "PRIVATE": "*", "INTERFACE": "*"}, + }, + "target_include_directories": { + "pargs": "*", + "flags": ["SYSTEM"], + "kwargs": {"PUBLIC": "*", "PRIVATE": "*", "INTERFACE": "*"}, + }, + "set_target_properties": { + "pargs": "*", + "flags": ["PROPERTIES"], + "kwargs": { + "OUTPUT_NAME": "1", + "EXPORT_NAME": "1", + "LINKER_LANGUAGE": "1", + "CMAKE_CXX_STANDARD_REQUIRED": "1", + "COMPILE_DEFINITIONS": "1", + "COMPILE_OPTIONS": "1", + "VERSION": "1", + "SOVERSION": "1", + }, + }, + "SET_UP_GEN_FILES": { + "kwargs": { + "ADDITIONAL_OUTPUTS": "+", + "FDEPL_FILE": 1, + "FIDL_FILE": 1, + "INSTALL_HEADERS_DIR": 1, + "INTERFACES": "+", + "MIDDLEWARE": 1, + "OUTPUT_DIR": 1, + "TOP_PREFIX": 1, + "VAR_PREFIX": 1, + "VAR_PREFIXES": "+", + "VERSION": 1, + "VERSIONS": "+", + }, + "pargs": { + "flags": ["DO_CORE_RERUN_WITH_FDEPL", "NO_CLOBBER"], + "nargs": "*", + }, + }, + "CREATE_VSOMEIP_CONFIG_FILE": { + "kwargs": { + "INSTANCE_ID": "*", + "VSOMEIP_JSON_FILE": "*", + "KEY": "*", + "JSON_GLOBS": "*", + } + }, + "install": { + "kwargs": { + "TARGETS": _install_type_args, + "FILES": _files_install_type_args, + "DIRECTORY": _directory_install_type_args, + "INCLUDES DESTINATION": "*", + "FILES_MATCHING": { + "kwargs": { + "PATTERN": "*", + "EXCLUDE PATTERN": "*", + } + }, + }, + }, + "list": { + # "pargs": "*", + "kwargs": { + "APPEND": "1", + "FILTER": "1", + # "INSERT": "1", + # "POP_BACK": "1", + }, + }, + } + + # Override configurations per-command where available + override_spec = {} + + # Specify variable tags. + vartags = [] + + # Specify property tags. + proptags = [] + +# ----------------------------- +# Options affecting formatting. +# ----------------------------- +with section("format"): + # Disable formatting entirely, making cmake-format a no-op + disable = False + + # How wide to allow formatted cmake files + line_width = 120 + + # How many spaces to tab for indent + tab_size = 2 + + # If true, lines are indented using tab characters (utf-8 0x09) instead of + # space characters (utf-8 0x20). In cases where the layout would + # require a fractional tab character, the behavior of the fractional + # indentation is governed by + use_tabchars = False + + # If is True, then the value of this variable indicates how + # fractional indentions are handled during whitespace replacement. If set to + # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set + # to `round-up` fractional indentation is replaced with a single tab character + # (utf-8 0x09) effectively shifting the column to the next tabstop + fractional_tab_policy = "use-space" + + # If an argument group contains more than this many sub-groups (parg or kwarg + # groups) then force it to a vertical layout. + max_subgroups_hwrap = 2 + + # If a positional argument group contains more than this many arguments, then + # force it to a vertical layout. + max_pargs_hwrap = 3 + + # If a cmdline positional group consumes more than this many lines without + # nesting, then invalidate the layout (and nest) + max_rows_cmdline = 2 + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = False + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = True + + # If the trailing parenthesis must be 'dangled' on its on line, then align it + # to this reference: `prefix`: the start of the statement, `prefix-indent`: + # the start of the statement, plus one indentation level, `child`: align to + # the column of the arguments + dangle_align = "prefix" + + # If the statement spelling length (including space and parenthesis) is + # smaller than this amount, then force reject nested layouts. + min_prefix_chars = 4 + + # If the statement spelling length (including space and parenthesis) is larger + # than the tab width by more than this amount, then force reject un-nested + # layouts. + max_prefix_chars = 10 + + # If a candidate layout is wrapped horizontally but it exceeds this many + # lines, then reject the layout. + max_lines_hwrap = 2 + + # What style line endings to use in the output. + line_ending = "unix" + + # Format command names consistently as 'lower' or 'upper' case + command_case = "canonical" + + # Format keywords consistently as 'lower' or 'upper' case + keyword_case = "unchanged" + + # A list of command names which should always be wrapped + always_wrap = [] + + # If true, the argument lists which are known to be sortable will be sorted + # lexicographicall + enable_sort = True + + # If true, the parsers may infer whether or not an argument list is sortable + # (without annotation). + autosort = False + + # By default, if cmake-format cannot successfully fit everything into the + # desired linewidth it will apply the last, most agressive attempt that it + # made. If this flag is True, however, cmake-format will print error, exit + # with non-zero status code, and write-out nothing + require_valid_layout = False + + # A dictionary mapping layout nodes to a list of wrap decisions. See the + # documentation for more information. + layout_passes = {} + +# ------------------------------------------------ +# Options affecting comment reflow and formatting. +# ------------------------------------------------ +with section("markup"): + # What character to use for bulleted lists + bullet_char = "*" + + # What character to use as punctuation after numerals in an enumerated list + enum_char = "." + + # If comment markup is enabled, don't reflow the first comment block in each + # listfile. Use this to preserve formatting of your copyright/license + # statements. + first_comment_is_literal = False + + # If comment markup is enabled, don't reflow any comment block which matches + # this (regex) pattern. Default is `None` (disabled). + literal_comment_pattern = None + + # Regular expression to match preformat fences in comments default= + # ``r'^\s*([`~]{3}[`~]*)(.*)$'`` + fence_pattern = "^\\s*([`~]{3}[`~]*)(.*)$" + + # Regular expression to match rulers in comments default= + # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'`` + ruler_pattern = "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$" + + # If a comment line matches starts with this pattern then it is explicitly a + # trailing comment for the preceeding argument. Default is '#<' + explicit_trailing_pattern = "#<" + + # If a comment line starts with at least this many consecutive hash + # characters, then don't lstrip() them off. This allows for lazy hash rulers + # where the first hash char is not separated by space + hashruler_min_length = 10 + + # If true, then insert a space between the first hash char and remaining hash + # chars in a hash ruler, and normalize its length to fill the column + canonicalize_hashrulers = True + + # enable comment markup parsing and reflow + enable_markup = True + +# ---------------------------- +# Options affecting the linter +# ---------------------------- +with section("lint"): + # a list of lint codes to disable + disabled_codes = [] + + # regular expression pattern describing valid function names + function_pattern = "[0-9a-z_]+" + + # regular expression pattern describing valid macro names + macro_pattern = "[0-9A-Z_]+" + + # regular expression pattern describing valid names for variables with global + # (cache) scope + global_var_pattern = "[A-Z][0-9A-Z_]+" + + # regular expression pattern describing valid names for variables with global + # scope (but internal semantic) + internal_var_pattern = "_[A-Z][0-9A-Z_]+" + + # regular expression pattern describing valid names for variables with local + # scope + local_var_pattern = "[a-z][a-z0-9_]+" + + # regular expression pattern describing valid names for privatedirectory + # variables + private_var_pattern = "_[0-9a-z_]+" + + # regular expression pattern describing valid names for public directory + # variables + public_var_pattern = "[A-Z][0-9A-Z_]+" + + # regular expression pattern describing valid names for function/macro + # arguments and loop variables. + argument_var_pattern = "[a-z][a-z0-9_]+" + + # regular expression pattern describing valid names for keywords used in + # functions or macros + keyword_pattern = "[A-Z][0-9A-Z_]+" + + # In the heuristic for C0201, how many conditionals to match within a loop in + # before considering the loop a parser. + max_conditionals_custom_parser = 2 + + # Require at least this many newlines between statements + min_statement_spacing = 1 + + # Require no more than this many newlines between statements + max_statement_spacing = 2 + max_returns = 6 + max_branches = 12 + max_arguments = 5 + max_localvars = 15 + max_statements = 50 + +# ------------------------------- +# Options affecting file encoding +# ------------------------------- +with section("encode"): + # If true, emit the unicode byte-order mark (BOM) at the start of the file + emit_byteorder_mark = False + + # Specify the encoding of the input file. Defaults to utf-8 + input_encoding = "utf-8" + + # Specify the encoding of the output file. Defaults to utf-8. Note that cmake + # only claims to support utf-8 so be careful when using anything else + output_encoding = "utf-8" + +# ------------------------------------- +# Miscellaneous configurations options. +# ------------------------------------- +with section("misc"): + # A dictionary containing any per-command configuration overrides. Currently + # only `command_case` is supported. + per_command = {} diff --git a/.gitignore b/.gitignore index e2d8aa8ee..f36b66404 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,12 @@ +/Makefile +/.vscode +/.cache +/compile_commands.json +/.ninja /CMakeFiles /build*/* +/*bld* +/*stage /examples/hello_world/build /.idea/ /.vs/ diff --git a/CMakeLists.txt b/CMakeLists.txt index facbb5d21..293c681dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,431 +1,628 @@ -# Copyright (C) 2015-2023 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/. +# Copyright (C) 2015-2023 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.13) -project (vsomeip) +cmake_minimum_required(VERSION 3.13) -set (VSOMEIP_NAME vsomeip3) -set (VSOMEIP_COMPAT_NAME vsomeip) +if(POLICY CMP0177) + # Non-normalized paths in install, see comment below + cmake_policy(SET CMP0177 OLD) +endif() +if(POLICY CMP0167) + # Use CMake's FindBoost module, see comment below. Needed until minimum + # boost version is >=1.70 + cmake_policy(SET CMP0167 NEW) +endif() +if(POLICY CMP0144) + # find_package uses upper-case _ROOT variables + cmake_policy(SET CMP0144 NEW) +endif() -set (VSOMEIP_MAJOR_VERSION 3) -set (VSOMEIP_MINOR_VERSION 5) -set (VSOMEIP_PATCH_VERSION 5) -set (VSOMEIP_HOTFIX_VERSION 0) +project(vsomeip) -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) +set(VSOMEIP_NAME vsomeip3) +set(VSOMEIP_COMPAT_NAME vsomeip) -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() +set(VSOMEIP_MAJOR_VERSION 3) +set(VSOMEIP_MINOR_VERSION 5) +set(VSOMEIP_PATCH_VERSION 5) +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 + +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 -################################################################################################### +# ###################################################################################################################### + +include(GNUInstallDirs) # 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") +set(INSTALL_LIB_DIR + ${CMAKE_INSTALL_LIBDIR} + CACHE PATH "Installation directory for libraries" +) +set(INSTALL_BIN_DIR + ${CMAKE_INSTALL_BINDIR} + CACHE PATH "Installation directory for executables" +) +set(INSTALL_INCLUDE_DIR + ${CMAKE_INSTALL_INCLUDEDIR} + 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 () +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") +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 () - -################################################################################################### +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 +# This is a CMake anti-pattern. 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(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") + set_property( + CACHE CMAKE_BUILD_TYPE + PROPERTY STRINGS + "Debug" + "Release" + "MinSizeRel" + "RelWithDebInfo" + ) endif() set(CMAKE_CXX_STANDARD 17) +# Threads +find_package(Threads REQUIRED) + # OS -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(DL_LIBRARY "dl") +add_library(OS_INTERFACE INTERFACE IMPORTED) +add_library(RT_INTERFACE INTERFACE IMPORTED) +add_library(DL_INTERFACE INTERFACE IMPORTED) + +# Boost, once this is pushed pased 1.70, it should be found using CONFIG rather +# than CMake's FindBoost module, see policy CMP0167 +find_package( + Boost 1.66 REQUIRED + COMPONENTS system thread filesystem +) -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 -Wno-tsan -Wl,-z,relro,-z,now") +include(CMakeDependentOption) +cmake_dependent_option( + ENABLE_WERROR + "Enable -Werror flag" + ON + "CMAKE_SYSTEM_NAME MATCHES LINUX" + OFF +) +if(ENABLE_WERROR) + message(STATUS "Enabling -Werror flag") + add_compile_options(-Werror) endif() - set(NO_DEPRECATED "") - set(OPTIMIZE "") +# Variable to store compiler options used to export settings. These are stored +# in a variable such that they can be easily removed in test apps (see +# test/CMakeLists.txt) +set(EXPORTSYMBOLS) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(OS "LINUX") + target_link_libraries(DL_INTERFACE INTERFACE dl) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) if(NOT DEFINED _FORTIFY_SOURCE) - set(_FORTIFY_SOURCE 2) + set(_FORTIFY_SOURCE 2) + endif() + add_definitions(-D_GLIBCXX_USE_NANOSLEEP -D_FORTIFY_SOURCE=${_FORTIFY_SOURCE}) + add_compile_options( + -Wall + -Wextra + -Wformat + -Wformat-security + -Wconversion + -Wformat + -Werror=format-security + -Wpedantic + -fexceptions + -fstrict-aliasing + -fstack-protector-strong + -fasynchronous-unwind-tables + -fno-omit-frame-pointer + ) + + # Check if optimization level is set in CMAKE_CXX_FLAGS_RELWITHDEBINFO + string(REGEX MATCH "-O([0-3s]?)" OPTIMIZATION_SET "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + + if(NOT OPTIMIZATION_SET) + message(WARNING "No optimization level set in CMAKE_CXX_FLAGS_RELWITHDEBINFO, adding -O") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O") + endif() + + target_link_libraries(OS_INTERFACE INTERFACE Threads::Threads) + + 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 + ) + + target_link_options( + OS_INTERFACE + INTERFACE + -Wl,-z,relro,-z,now + ${EXPORTSYMBOLS} + ) + + # There appear to be complication issues without this flag + target_link_options(OS_INTERFACE INTERFACE -Wno-tsan) endif() - 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=${_FORTIFY_SOURCE} -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#################################### + target_link_options(OS_INTERFACE INTERFACE -Wl,--wrap=socket,--wrap=accept,--wrap=open) + + # 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) + +elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(OS "FREEBSD") + add_compile_options(-Wno-deprecated) + target_link_libraries(OS_INTERFACE INTERFACE Threads::Threads) + target_link_options(OS_INTERFACE INTERFACE -Wl,--wrap=socket,--wrap=accept,--wrap=open) + +elseif(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + set(OS "QNX") + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + add_compile_options( + -fexceptions + -fstrict-aliasing + -fstack-protector + -fasynchronous-unwind-tables + -fno-omit-frame-pointer + ) + target_link_options(OS_INTERFACE INTERFACE -Wl,-export-dynamic) + target_link_options(OS_INTERFACE INTERFACE -Wl,--wrap=socket,--wrap=accept,--wrap=open) + + target_link_libraries(OS_INTERFACE INTERFACE slog2) + + # QNX specific socket lib + set(VSOMEIP_SOCKET_LIB + "socket" + CACHE STRING "Default socket library for QNX" + ) + target_link_libraries(RT_INTERFACE INTERFACE $<$:${VSOMEIP_SOCKET_LIB}>) + +endif() + +if(${OS}) + add_definitions(-D${OS}) +endif() + +# ###################################My lib link flags############################## # Options -################################################################################ +# ################################################################################## + +find_package(PkgConfig) # DLT -if (DISABLE_DLT) -set (VSOMEIP_ENABLE_DLT 0) -else () -set (VSOMEIP_ENABLE_DLT 1) -endif () +option(DISABLE_DLT "Disable DLT support" OFF) +if(NOT ${DISABLE_DLT}) + pkg_check_modules(DLT "automotive-dlt >= 2.11" IMPORTED_TARGET) + if(DLT_FOUND) + message(STATUS "automotive-dlt found and will be linked") + add_compile_definitions(USE_DLT) + endif() +else() + message(STATUS "Not linking automotive-dlt") +endif() # Signal handling -if (ENABLE_SIGNAL_HANDLING) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_SIGNAL_HANDLING") -endif () +option(ENABLE_SIGNAL_HANDLING "Enable signal handling (SIGTERM, SIGINT, etc) in applicaiton_impl" OFF) +if(ENABLE_SIGNAL_HANDLING) + add_definitions(-DVSOMEIP_ENABLE_SIGNAL_HANDLING) +endif() # Event caching -if (ENABLE_DEFAULT_EVENT_CACHING) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_DEFAULT_EVENT_CACHING") -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 () - - # Valgrind - find_program(VALGRIND "valgrind") - if (VALGRIND) - if (DEFINED VALGRIND_TYPE AND NOT VALGRIND_TYPE STREQUAL "") - set(TEST_ENTRYPOINT ${VALGRIND} --tool=${VALGRIND_TYPE} --trace-children=yes) - add_definitions(-DBOOST_USE_VALGRIND) - endif () - - if (VALGRIND_TYPE STREQUAL "helgrind") - set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --show-error-list=yes --suppressions=${VALGRIND_SUPPRESS_FILE} --gen-suppressions=all --log-file=${VALGRIND_LOGS_DIR}/test_name.out) - endif () - - if (VALGRIND_TYPE STREQUAL "massif") - set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --massif-out-file=${VALGRIND_LOGS_DIR}/test_name.out) - endif () - - if (VALGRIND_TYPE STREQUAL "memcheck") - set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --leak-check=yes --suppressions=${VALGRIND_SUPPRESS_FILE} --log-file=${VALGRIND_LOGS_DIR}/test_name.out) - endif () - endif () -endif (NOT MSVC) +option(ENABLE_DEFAULT_EVENT_CACHING "Enable default event caching") -# Compatibility -if (ENABLE_COMPAT) -set (VSOMEIP_ENABLE_COMPAT 1) -else () -set (VSOMEIP_ENABLE_COMPAT 0) -endif () +if(NOT MSVC) + # Sanitizers -# Multiple routing managers -if (ENABLE_MULTIPLE_ROUTING_MANAGERS) -set (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS 1) -else () -set (VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS 0) -endif () + if(ENABLE_UNDEFINED_SANITIZER) + add_compile_options(-fsanitize=undefined) + add_link_options(-fsanitize=undefined) + endif() -# Security / Policy handling -if (DISABLE_SECURITY) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_DISABLE_SECURITY") -endif () + if(ENABLE_THREAD_SANITIZER) + add_compile_options(-fsanitize=thread) + add_link_options(-fsanitize=thread) + endif() -# Suppress deprecation warnings for vSomeIP interfaces -add_definitions(-DVSOMEIP_INTERNAL_SUPPRESS_DEPRECATED) + if(ENABLE_LEAK_SANITIZER) + add_compile_options(-fsanitize=leak) + add_link_options(-fsanitize=leak) + endif() -################################################################################ -# Dependencies -################################################################################ + if(ENABLE_ADDRESS_SANITIZER) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) + endif() -# Threads -find_package(Threads REQUIRED) + if(ENABLE_PROFILING) + add_compile_options(-pg) + endif() -# Boost -find_package( Boost 1.66 COMPONENTS system thread filesystem REQUIRED ) -if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") - include_directories(${Boost_INCLUDE_DIR} ) -else() - include_directories(SYSTEM ${Boost_INCLUDE_DIR} ) -endif() + # Valgrind + find_program(VALGRIND "valgrind") + if(VALGRIND) + if(DEFINED VALGRIND_TYPE + AND NOT + VALGRIND_TYPE + STREQUAL + "" + ) + set(TEST_ENTRYPOINT ${VALGRIND} --tool=${VALGRIND_TYPE} --trace-children=yes) + add_definitions(-DBOOST_USE_VALGRIND) + endif() -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}) + if(VALGRIND_TYPE STREQUAL "helgrind") + set(TEST_ENTRYPOINT + ${TEST_ENTRYPOINT} + --show-error-list=yes + --suppressions=${VALGRIND_SUPPRESS_FILE} + --gen-suppressions=all + --log-file=${VALGRIND_LOGS_DIR}/test_name.out + ) + endif() + + if(VALGRIND_TYPE STREQUAL "massif") + set(TEST_ENTRYPOINT ${TEST_ENTRYPOINT} --massif-out-file=${VALGRIND_LOGS_DIR}/test_name.out) + endif() + + if(VALGRIND_TYPE STREQUAL "memcheck") + set(TEST_ENTRYPOINT + ${TEST_ENTRYPOINT} + --leak-check=yes + --suppressions=${VALGRIND_SUPPRESS_FILE} + --log-file=${VALGRIND_LOGS_DIR}/test_name.out + ) endif() endif() -else() - MESSAGE( STATUS "Boost was not found!") endif() +# Compatibility +option(ENABLE_COMPAT "Enable compatibility layer" OFF) + +# Multiple routing managers +option(ENABLE_MULTIPLE_ROUTING_MANAGERS "Enable multiple routing managers" OFF) + +# Security / Policy handling +option(DISABLE_SECURITY "Disable security features") +if(DISABLE_SECURITY) + add_definitions(-DVSOMEIP_DISABLE_SECURITY) +endif() + +# Suppress deprecation warnings for vSomeIP interfaces +add_definitions(-DVSOMEIP_INTERNAL_SUPPRESS_DEPRECATED) + +# ###################################################################################################################### +# Dependencies +# ###################################################################################################################### + # cmake 3.15 introduced a new variable and a new format for the old one -if (DEFINED Boost_VERSION_MACRO) +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}" ) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_BOOST_VERSION=${VSOMEIP_BOOST_VERSION}") - -find_package(PkgConfig) +message(STATUS "Using boost version: ${VSOMEIP_BOOST_VERSION}") -# 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() +add_definitions(-DVSOMEIP_BOOST_VERSION=${VSOMEIP_BOOST_VERSION}) # 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 () +if(NOT SystemD_FOUND OR ${CMAKE_SYSTEM_NAME} MATCHES "Android") + message(STATUS "Systemd was not found, watchdog disabled!") + add_definitions(-DWITHOUT_SYSTEMD) +else() + target_link_libraries(OS_INTERFACE INTERFACE ${SystemD_LIBRARIES}) +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}") +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 -D_WIN32 -DBOOST_ASIO_DISABLE_IOCP /EHsc /wd4250") - set(USE_RT "") - link_directories(${Boost_LIBRARY_DIR_DEBUG}) - add_compile_options(/MD$<$:d>) + 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. + add_compile_options(/EHsc /wd4250) + add_definitions( + -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 + ) + link_directories(${Boost_LIBRARY_DIR_DEBUG}) + add_compile_options(/MD$<$:d>) elseif(${CMAKE_SYSTEM_NAME} MATCHES "QNX") - set(USE_RT "") + # Do not apply rt on QNX else() - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OS_CXX_FLAGS} -g ${OPTIMIZE} ${NO_DEPRECATED} ${EXPORTSYMBOLS}") - set(USE_RT "rt") + target_link_libraries(RT_INTERFACE INTERFACE 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}) - target_compile_features(${VSOMEIP_NAME}-cfg PRIVATE cxx_std_17) - 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 () +# ###################################################################################################################### +file(GLOB vsomeip_cfg_SRC "implementation/configuration/src/*.cpp") +list(SORT vsomeip_cfg_SRC) +if(NOT ENABLE_MULTIPLE_ROUTING_MANAGERS) + add_library(${VSOMEIP_NAME}-cfg SHARED) + target_sources(${VSOMEIP_NAME}-cfg PRIVATE ${vsomeip_cfg_SRC}) + set_target_properties( + ${VSOMEIP_NAME}-cfg PROPERTIES + VERSION ${VSOMEIP_VERSION} + SOVERSION ${VSOMEIP_MAJOR_VERSION} + OUTPUT_NAME ${VSOMEIP_NAME}-cfg + EXPORT_NAME vsomeip3-cfg + ) + target_compile_features(${VSOMEIP_NAME}-cfg PRIVATE cxx_std_17) + target_compile_definitions(${VSOMEIP_NAME}-cfg PUBLIC $<$:VSOMEIP_DLL_COMPILATION_PLUGIN>) + + target_link_libraries( + ${VSOMEIP_NAME}-cfg + PRIVATE ${VSOMEIP_NAME} + Boost::filesystem + Boost::thread + RT_INTERFACE + DL_INTERFACE + OS_INTERFACE + ) +else() + # We don't want this target to only conditionally exist. + add_library(${VSOMEIP_NAME}-cfg INTERFACE) + message(STATUS "Multiple routing managers enabled, \"disabling\" the + configuration library. Note that the unittests depend on this library so you + won't likely be able to use the tests in this mode" + ) +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" +# ###################################################################################################################### +file( + GLOB + vsomeip3_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") +if(ENABLE_MULTIPLE_ROUTING_MANAGERS) + list(APPEND vsomeip3_SRC "implementation/configuration/src/configuration_impl.cpp") endif() - -if (WIN32) -list(FILTER ${VSOMEIP_NAME}_SRC EXCLUDE REGEX ".*uds.*") +list(SORT vsomeip3_SRC) + +if(WIN32) + list( + FILTER vsomeip3_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}) +add_library(${VSOMEIP_NAME} SHARED) +target_sources(${VSOMEIP_NAME} PRIVATE ${vsomeip3_SRC}) target_compile_features(${VSOMEIP_NAME} PRIVATE cxx_std_17) -if (MSVC) - set_target_properties(${VSOMEIP_NAME} PROPERTIES COMPILE_DEFINITIONS "VSOMEIP_DLL_COMPILATION") - set_target_properties(${VSOMEIP_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) -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 - $ - $ - $) -# 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}) +target_include_directories( + ${VSOMEIP_NAME} + PUBLIC $ + $ + INTERFACE $ +) +if(MSVC) + set_target_properties( + ${VSOMEIP_NAME} + PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS + ON + ) +endif() +target_compile_definitions( + ${VSOMEIP_NAME} + PRIVATE $<$:VSOMEIP_DLL_COMPILATION> + $<$:VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS> + $<$:VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING> +) +target_include_directories(${VSOMEIP_NAME} SYSTEM PUBLIC $) +set_target_properties( + ${VSOMEIP_NAME} PROPERTIES + SOVERSION ${VSOMEIP_MAJOR_VERSION} + VERSION ${VSOMEIP_VERSION} + OUTPUT_NAME ${VSOMEIP_NAME} + EXPORT_NAME vsomeip3 +) + +# 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 library +# 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::filesystem + Boost::thread + $ + RT_INTERFACE + DL_INTERFACE + OS_INTERFACE + Threads::Threads +) if(NOT WIN32) - target_link_options(${VSOMEIP_NAME} PRIVATE "LINKER:-as-needed") + 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) +# ###################################################################################################################### +file(GLOB vsomeip_sd_SRC "implementation/service_discovery/src/*.cpp") +list(SORT vsomeip_sd_SRC) -add_library(${VSOMEIP_NAME}-sd SHARED ${${VSOMEIP_NAME}-sd_SRC}) +add_library(${VSOMEIP_NAME}-sd SHARED) target_compile_features(${VSOMEIP_NAME}-sd PRIVATE cxx_std_17) -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}) - +target_sources(${VSOMEIP_NAME}-sd PRIVATE ${vsomeip_sd_SRC}) +set_target_properties( + ${VSOMEIP_NAME}-sd PROPERTIES + VERSION ${VSOMEIP_VERSION} + SOVERSION ${VSOMEIP_MAJOR_VERSION} + OUTPUT_NAME ${VSOMEIP_NAME}-sd + EXPORT_NAME vsomeip3-sd +) +target_compile_definitions(${VSOMEIP_NAME}-sd PUBLIC $<$:VSOMEIP_DLL_COMPILATION_PLUGIN>) +target_link_libraries( + ${VSOMEIP_NAME}-sd + PUBLIC ${VSOMEIP_NAME} + PRIVATE RT_INTERFACE + DL_INTERFACE + OS_INTERFACE + Threads::Threads +) -################################################################################ +# ###################################################################################################################### # E2E library -################################################################################ -file(GLOB_RECURSE ${VSOMEIP_NAME}-e2e_SRC - "implementation/e2e_protection/src/*.cpp" +# ###################################################################################################################### +file(GLOB_RECURSE vsomeip_e2e_SRC "implementation/e2e_protection/src/*.cpp") +list(SORT vsomeip_e2e_SRC) + +add_library(${VSOMEIP_NAME}-e2e SHARED) +target_sources(${VSOMEIP_NAME}-e2e PRIVATE ${vsomeip_e2e_SRC}) +set_target_properties( + ${VSOMEIP_NAME}-e2e PROPERTIES + VERSION ${VSOMEIP_VERSION} + SOVERSION ${VSOMEIP_MAJOR_VERSION} + OUTPUT_NAME ${VSOMEIP_NAME}-e2e + EXPORT_NAME vsomeip3-e2e +) +target_compile_definitions(${VSOMEIP_NAME}-e2e PUBLIC $<$:VSOMEIP_DLL_COMPILATION_PLUGIN>) +target_link_libraries( + ${VSOMEIP_NAME}-e2e + PUBLIC ${VSOMEIP_NAME} + PRIVATE RT_INTERFACE DL_INTERFACE OS_INTERFACE ) -list(SORT ${VSOMEIP_NAME}-e2e_SRC) - -add_library(${VSOMEIP_NAME}-e2e SHARED ${${VSOMEIP_NAME}-e2e_SRC}) -target_compile_features(${VSOMEIP_NAME}-e2e PRIVATE cxx_std_17) -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}) -if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") - target_link_directories(${VSOMEIP_NAME} PUBLIC "${QNX_TARGET}/${CPUVARDIR}/io-sock/lib") - target_link_libraries(${VSOMEIP_NAME}-e2e socket) - target_link_libraries(${VSOMEIP_NAME}-cfg socket) - target_link_libraries(${VSOMEIP_NAME}-sd socket) - target_link_libraries(${VSOMEIP_NAME} PRIVATE socket) -endif() -################################################################################ +# ###################################################################################################################### # Compatibility library -################################################################################ -if (VSOMEIP_ENABLE_COMPAT EQUAL 1) -set (VSOMEIP_COMPAT_MAJOR_VERSION 2) -set (VSOMEIP_COMPAT_VERSION ${VSOMEIP_COMPAT_MAJOR_VERSION}.99.99) +# ###################################################################################################################### +if(ENABLE_COMPAT) + 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") + add_definitions(-DVSOMEIP_ENABLE_COMPAT) -file(GLOB_RECURSE ${VSOMEIP_COMPAT_NAME}_SRC + file( + GLOB_RECURSE + vsomeip_compat_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}) -target_compile_features(${VSOMEIP_COMPAT_NAME} PRIVATE cxx_std_17) -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 () + ) + list(SORT vsomeip_compat_SRC) + + add_library(${VSOMEIP_NAME}-compat SHARED ${vsomeip_compat_SRC}) + target_compile_features(${VSOMEIP_NAME}-compat PRIVATE cxx_std_17) + target_compile_definitions(${VSOMEIP_NAME}-compat PUBLIC $<$:VSOMEIP_DLL_COMPILATION_PLUGIN>) + set_target_properties( + ${VSOMEIP_NAME}-compat PROPERTIES + VERSION ${VSOMEIP_COMPAT_VERSION} + SOVERSION ${VSOMEIP_COMPAT_MAJOR_VERSION} + OUTPUT_NAME ${VSOMEIP_COMPAT_NAME} + EXPORT_NAME vsomeip-compat + ) + target_include_directories( + ${VSOMEIP_NAME}-compat + PUBLIC # Access to vsomeip3 includes + $ # Access to vsomeip3 includes + $ + $ + $ # for generated files in build mode + $ + $ # for clients in install mode + ) + target_link_libraries( + ${VSOMEIP_NAME}-compat + PRIVATE ${VSOMEIP_NAME} + Boost::system + Boost::thread + RT_INTERFACE + DL_INTERFACE + OS_INTERFACE + ) -target_include_directories( - ${VSOMEIP_COMPAT_NAME} - PUBLIC - $ - $ # for generated files in build mode - $ # for clients in install mode -) -target_link_libraries(${VSOMEIP_COMPAT_NAME} PRIVATE ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES}) - -endif () +endif() -################################################################################ +# ###################################################################################################################### # Configuration files -################################################################################ +# ###################################################################################################################### set(EXAMPLE_CONFIG_FILES "config/vsomeip.json" "config/vsomeip-local.json" @@ -435,51 +632,58 @@ set(EXAMPLE_CONFIG_FILES "config/vsomeip-udp-service.json" ) -################################################################################ +# ###################################################################################################################### # Configuration parameters -################################################################################ +# ###################################################################################################################### if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") - set (VSOMEIP_BASE_PATH "/var") + set(VSOMEIP_BASE_PATH_DEFAULT "/var") else() - set (VSOMEIP_BASE_PATH "/tmp") -endif() -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 (VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME 100) -if (LOCAL_TCP_PORT_WAIT_TIME) -set (VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME ${LOCAL_TCP_PORT_WAIT_TIME}) -endif () - -set (VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME 10000) -if (LOCAL_TCP_PORT_MAX_WAIT_TIME) -if (${LOCAL_TCP_PORT_MAX_WAIT_TIME} GREATER ${LOCAL_TCP_PORT_WAIT_TIME}) -set (VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME ${LOCAL_TCP_PORT_MAX_WAIT_TIME}) -else () -set (VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME ${LOCAL_TCP_PORT_WAIT_TIME}) -endif () -endif () - -set(DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" CACHE PATH "Default configuration folder") + set(VSOMEIP_BASE_PATH_DEFAULT "/tmp") +endif() +set(VSOMEIP_BASE_PATH + ${VSOMEIP_BASE_PATH_DEFAULT} + CACHE PATH "Base path for vsomeip sockets" +) + +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(VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME 100) +if(LOCAL_TCP_PORT_WAIT_TIME) + set(VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME ${LOCAL_TCP_PORT_WAIT_TIME}) +endif() + +set(VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME 10000) +if(LOCAL_TCP_PORT_MAX_WAIT_TIME) + if(${LOCAL_TCP_PORT_MAX_WAIT_TIME} GREATER ${LOCAL_TCP_PORT_WAIT_TIME}) + set(VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME ${LOCAL_TCP_PORT_MAX_WAIT_TIME}) + else() + set(VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME ${LOCAL_TCP_PORT_WAIT_TIME}) + endif() +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") +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}") @@ -487,202 +691,246 @@ message("Predefined unicast address: ${VSOMEIP_UNICAST_ADDRESS}") message("Predefined diagnosis address: ${VSOMEIP_DIAGNOSIS_ADDRESS}") message("Predefined wait times for internal communication ports (TCP):\ ${VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME}\ - (max=${VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME})") + (max=${VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME})" +) -################################################################################ +# ###################################################################################################################### # 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 -) +set(INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/interface/vsomeip") -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 +file( + GLOB_RECURSE + vsomeip_INCLUDE + RELATIVE + ${INCLUDE_PATH} + "interface/*.h*" ) -endif () +list(SORT vsomeip_INCLUDE) + +foreach(file ${vsomeip_INCLUDE}) + get_filename_component(dir ${file} DIRECTORY) + # The destination contains non-normalized paths, this is deprecated. Until + # CMake 3.23 is the minimum version and FILE_SETs can be used, we're relying + # on using the old CMP0177 policy. + install( + FILES "${INCLUDE_PATH}/${file}" + DESTINATION "${INSTALL_INCLUDE_DIR}/vsomeip/${dir}" + COMPONENT dev + ) +endforeach() -install ( - TARGETS ${VSOMEIP_NAME}-sd - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin +unset(INCLUDE_PATH) +unset(vsomeip_INCLUDE) +unset(file) + +install( + TARGETS ${VSOMEIP_NAME} + # IMPORTANT: Add the vsomeip library to the "export-set" + EXPORT ${VSOMEIP_NAME}Targets + RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT bin + LIBRARY + DESTINATION "${INSTALL_LIB_DIR}" + COMPONENT shlib + ARCHIVE + DESTINATION "${INSTALL_LIB_DIR}" + COMPONENT dev ) -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 +install( + TARGETS ${VSOMEIP_NAME}-e2e 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 -) +if(NOT ENABLE_MULTIPLE_ROUTING_MANAGERS) + install( + TARGETS ${VSOMEIP_NAME}-cfg LIBRARY + DESTINATION "${INSTALL_LIB_DIR}" + COMPONENT shlib + RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT bin + ) +endif() -install ( - FILES - "${PROJECT_BINARY_DIR}/vsomeipConfig.cmake" - "${PROJECT_BINARY_DIR}/vsomeipConfigVersion.cmake" - DESTINATION "${COMPAT_INSTALL_CMAKE_DIR}" - COMPONENT dev +install( + TARGETS ${VSOMEIP_NAME}-sd LIBRARY + DESTINATION "${INSTALL_LIB_DIR}" + COMPONENT shlib + RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT bin ) -configure_file(vsomeip.pc.in ${PROJECT_BINARY_DIR}/vsomeip.pc @ONLY) -install(FILES ${PROJECT_BINARY_DIR}/vsomeip.pc DESTINATION lib/pkgconfig) +if(ENABLE_COMPAT) + install( + TARGETS ${VSOMEIP_NAME}-compat + EXPORT vsomeipTargets + LIBRARY + DESTINATION "${INSTALL_LIB_DIR}" + COMPONENT shlib + RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT bin + ) + + export(TARGETS ${VSOMEIP_NAME}-compat FILE "${PROJECT_BINARY_DIR}/vsomeipTargets.cmake") + export(PACKAGE ${VSOMEIP_NAME}-compat) + + 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 "${DEF_INSTALL_CMAKE_DIR}-compat") + + 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 () +endif() -install ( - FILES ${EXAMPLE_CONFIG_FILES} DESTINATION etc/vsomeip COMPONENT config +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(TARGETS ${VSOMEIP_NAME} FILE "${PROJECT_BINARY_DIR}/vsomeip3Targets.cmake") -# Export the package for use from the build-tree -# (this registers the build-tree with a global CMake-registry) -export (PACKAGE ${VSOMEIP_NAME}) +# 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) +# Create the vsomeip3Config.cmake and vsomeip3ConfigVersion files +configure_file(vsomeip3Config.cmake.in "${PROJECT_BINARY_DIR}/vsomeip3Config.cmake" @ONLY) +configure_file(vsomeip3ConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/vsomeip3ConfigVersion.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" +configure_file( + "${PROJECT_SOURCE_DIR}/implementation/configuration/include/internal.hpp.in" + "${PROJECT_BINARY_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 vsomeip3Config.cmake and vsomeip3ConfigVersion.cmake +install( + FILES "${PROJECT_BINARY_DIR}/vsomeip3Config.cmake" "${PROJECT_BINARY_DIR}/vsomeip3ConfigVersion.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 +install( + EXPORT + vsomeip3Targets + 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.") +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() + # 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) + 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) + add_dependencies(doc doxygen-doc) 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) + configure_file(vsomeip3.pc.in ${PROJECT_BINARY_DIR}/vsomeip3.pc @ONLY) + install(FILES ${PROJECT_BINARY_DIR}/vsomeip3.pc DESTINATION lib/pkgconfig) endif() -############################################################################## -# build routing manager daemon and hello world examples (Non-Windows only) -if (NOT MSVC) -add_subdirectory( examples/routingmanagerd ) -add_subdirectory( examples/hello_world ) +# ###################################################################################################################### +# build routing manager daemon (Non-Windows only) +if(NOT MSVC) + add_subdirectory(examples/routingmanagerd) + add_subdirectory(examples/hello_world) endif() # build tools -add_custom_target( tools ) -add_subdirectory( tools/vsomeip_ctrl ) +add_custom_target(tools) +add_subdirectory(tools/vsomeip_ctrl) # build examples -add_custom_target( examples ) -add_subdirectory( examples EXCLUDE_FROM_ALL ) +add_custom_target(examples) +add_subdirectory(examples EXCLUDE_FROM_ALL) + +# ###################################################################################################################### -############################################################################## # add test directory enable_testing() -add_subdirectory( test EXCLUDE_FROM_ALL ) +add_subdirectory(test EXCLUDE_FROM_ALL) -if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") - install(DIRECTORY ${PROJECT_BINARY_DIR}/test/ - DESTINATION bin/vsomeip_tests/test - PATTERN "CMakeFiles" EXCLUDE - PATTERN "*.cmake" EXCLUDE - PATTERN "Makefile" EXCLUDE - ) - - install(FILES ${PROJECT_BINARY_DIR}/examples/routingmanagerd/routingmanagerd - DESTINATION bin/vsomeip_tests/examples/routingmanagerd) +if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") + install( + DIRECTORY ${PROJECT_BINARY_DIR}/test/ + DESTINATION bin/vsomeip_tests/test + PATTERN "CMakeFiles" EXCLUDE + PATTERN "*.cmake" EXCLUDE + PATTERN "Makefile" EXCLUDE + ) + + install(FILES ${PROJECT_BINARY_DIR}/examples/routingmanagerd/routingmanagerd + DESTINATION bin/vsomeip_tests/examples/routingmanagerd + ) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3ce54832c..51c80f440 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,8 @@ -# 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/. +# 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.13) set(EXAMPLE_CONFIG_FILES "../config/vsomeip.json" @@ -14,22 +15,53 @@ set(EXAMPLE_CONFIG_FILES # Examples add_executable(request-sample request-sample.cpp ${EXAMPLE_CONFIG_FILES}) -target_link_libraries(request-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY}) +target_link_libraries( + request-sample + ${VSOMEIP_NAME} + Boost::system + DL_INTERFACE +) add_executable(response-sample response-sample.cpp ${EXAMPLE_CONFIG_FILES}) -target_link_libraries(response-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY}) +target_link_libraries( + response-sample + ${VSOMEIP_NAME} + Boost::system + DL_INTERFACE +) add_executable(subscribe-sample subscribe-sample.cpp ${EXAMPLE_CONFIG_FILES}) -target_link_libraries(subscribe-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY}) +target_link_libraries( + subscribe-sample + ${VSOMEIP_NAME} + Boost::system + DL_INTERFACE +) add_executable(notify-sample notify-sample.cpp ${EXAMPLE_CONFIG_FILES}) -target_link_libraries(notify-sample ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY}) +target_link_libraries( + notify-sample + ${VSOMEIP_NAME} + Boost::system + DL_INTERFACE +) -add_dependencies(examples request-sample response-sample subscribe-sample notify-sample) +add_dependencies( + examples + request-sample + response-sample + subscribe-sample + notify-sample +) -install ( - TARGETS request-sample response-sample subscribe-sample notify-sample - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin +install( + TARGETS request-sample + response-sample + subscribe-sample + notify-sample + RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT bin ) -################################################################################################### +# ###################################################################################################################### diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index d528692e6..34bb705a6 100644 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -8,7 +8,7 @@ project (vSomeIPHelloWorld) find_package(Threads REQUIRED) -set(VSOMEIP_NAME "vsomeip3") +include(GNUInstallDirs) # create_target("executable") function(create_target executable) @@ -19,7 +19,7 @@ function(create_target executable) target_compile_features(vsomeip_hello_world_${executable} INTERFACE cxx_std_17) target_include_directories(vsomeip_hello_world_${executable} INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR} ) endfunction() @@ -28,10 +28,11 @@ function(link_target executable) add_executable(hello_world_${executable}) target_sources(hello_world_${executable} PRIVATE hello_world_${executable}_main.cpp) target_link_libraries(hello_world_${executable} PRIVATE vsomeip_hello_world_${executable} vsomeip3 Threads::Threads) + if(ENABLE_SIGNAL_HANDLING) + target_compile_definitions(vsomeip_hello_world_${executable} PRIVATE VSOMEIP_ENABLE_SIGNAL_HANDLING) + endif() endfunction() -include_directories(${VSOMEIP_INCLUDE_DIRS}) - create_target("service") create_target("client") @@ -46,4 +47,11 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android") link_target("client") link_target("service") + + install( + TARGETS + hello_world_client hello_world_service RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT example-hello_world + ) endif() diff --git a/examples/routingmanagerd/CMakeLists.txt b/examples/routingmanagerd/CMakeLists.txt index e8a2397fc..86a15b93e 100644 --- a/examples/routingmanagerd/CMakeLists.txt +++ b/examples/routingmanagerd/CMakeLists.txt @@ -1,25 +1,36 @@ -# Copyright (C) 2015-2023 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/. +# Copyright (C) 2015-2023 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.13) -# Daemon -add_executable(routingmanagerd routingmanagerd.cpp) -target_link_libraries(routingmanagerd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY} ${DLT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -if(${CMAKE_SYSTEM_NAME} MATCHES "QNX") - target_link_libraries(routingmanagerd socket) -endif() -add_dependencies(routingmanagerd ${VSOMEIP_NAME}) option(VSOMEIP_INSTALL_ROUTINGMANAGERD "Whether or not to install the routing manager daemon.") -if (VSOMEIP_INSTALL_ROUTINGMANAGERD) - install ( - TARGETS routingmanagerd - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin - ) -endif() +# Daemon +add_executable(routingmanagerd) +target_sources(routingmanagerd PRIVATE routingmanagerd.cpp) + +target_compile_definitions(routingmanagerd PRIVATE $) +target_link_libraries( + routingmanagerd + PRIVATE ${VSOMEIP_NAME} + Boost::system + Boost::filesystem + $ + OS_INTERFACE + DL_INTERFACE + RT_INTERFACE + Threads::Threads +) +if(VSOMEIP_INSTALL_ROUTINGMANAGERD) + install( + TARGETS routingmanagerd RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT bin + ) +endif() -################################################################################################### +# ###################################################################################################################### diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 3bfe28921..c7f982263 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -28,6 +28,7 @@ #include #include +#include "internal.hpp" #include "../include/client.hpp" #include "../include/configuration_impl.hpp" #include "../include/event.hpp" diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index fe2d00010..7ff5e664e 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -23,6 +23,7 @@ #include #include +#include "internal.hpp" #include "../include/application_impl.hpp" #ifdef VSOMEIP_ENABLE_MULTIPLE_ROUTING_MANAGERS #include "../../configuration/include/configuration_impl.hpp" diff --git a/interface/compat/vsomeip/message.hpp b/interface/compat/vsomeip/message.hpp index b7049eea6..dcd8761e8 100644 --- a/interface/compat/vsomeip/message.hpp +++ b/interface/compat/vsomeip/message.hpp @@ -8,7 +8,7 @@ #include -#include "../../compat/vsomeip/message_base.hpp" +#include namespace vsomeip { diff --git a/interface/compat/vsomeip/message_base.hpp b/interface/compat/vsomeip/message_base.hpp index ffc81fbef..24e7f2ac8 100644 --- a/interface/compat/vsomeip/message_base.hpp +++ b/interface/compat/vsomeip/message_base.hpp @@ -6,11 +6,11 @@ #ifndef VSOMEIP_MESSAGE_BASE_HPP #define VSOMEIP_MESSAGE_BASE_HPP -#include "../../compat/vsomeip/enumeration_types.hpp" -#include "../../compat/vsomeip/export.hpp" -#include "../../compat/vsomeip/internal/deserializable.hpp" -#include "../../compat/vsomeip/internal/serializable.hpp" -#include "../../compat/vsomeip/primitive_types.hpp" +#include +#include +#include +#include +#include namespace vsomeip { diff --git a/interface/compat/vsomeip/primitive_types.hpp b/interface/compat/vsomeip/primitive_types.hpp index ce1d4bd10..00113375b 100644 --- a/interface/compat/vsomeip/primitive_types.hpp +++ b/interface/compat/vsomeip/primitive_types.hpp @@ -8,6 +8,7 @@ #include #include +#include #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) #include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1a54604e8..f37309025 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,8 +14,16 @@ find_package(benchmark) ############################################################################## # google test -# remove export symbols from the cxx flags -string(REPLACE "${EXPORTSYMBOLS}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +# remove export symbols from the cxx flags. This is messy, but there's no `remove_link_flags` function +get_target_property(os_link_options OS_INTERFACE INTERFACE_LINK_OPTIONS) +foreach(opt IN ITEMS ${EXPORTSYMBOLS}) + list(REMOVE_ITEM os_link_options ${opt}) +endforeach() +unset(opt) +if(os_link_options) + set_target_properties(OS_INTERFACE PROPERTIES INTERFACE_LINK_OPTIONS "${os_link_options}") +endif() +unset(os_link_options) # check for set environment variable if(${GTEST_ROOT} STREQUAL "n/a") diff --git a/test/benchmark_tests/CMakeLists.txt b/test/benchmark_tests/CMakeLists.txt index e223c5ec5..141a4dcb8 100644 --- a/test/benchmark_tests/CMakeLists.txt +++ b/test/benchmark_tests/CMakeLists.txt @@ -1,11 +1,16 @@ -# Copyright (C) 2015-2023 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/. +# Copyright (C) 2015-2023 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/. -project ("benchmark_tests_bin" LANGUAGES CXX) +project("benchmark_tests_bin" LANGUAGES CXX) -file (GLOB SRCS main.cpp **/*.cpp) +file( + GLOB + SRCS + main.cpp + **/*.cpp + ../common/utility.cpp +) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -13,17 +18,20 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) # ---------------------------------------------------------------------------- # Executable and libraries to link # ---------------------------------------------------------------------------- -add_executable (${PROJECT_NAME} ${SRCS} ) -target_link_libraries ( - ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg - Threads::Threads - ${Boost_LIBRARIES} - ${DL_LIBRARY} - benchmark::benchmark - gtest - vsomeip_utilities +add_executable(vsomeip3-benchmark-tests) +target_sources(vsomeip3-benchmark-tests PRIVATE ${SRCS}) +target_link_libraries( + vsomeip3-benchmark-tests + PRIVATE ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg + vsomeip_utilities + Threads::Threads + Boost::filesystem + Boost::system + benchmark::benchmark + gtest + DL_INTERFACE ) +set_target_properties(vsomeip3-benchmark-tests PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) -add_dependencies(build_benchmark_tests ${PROJECT_NAME}) +add_dependencies(build_benchmark_tests vsomeip3-benchmark-tests) diff --git a/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp b/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp index c4bc047aa..1bf6658f1 100644 --- a/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp +++ b/test/benchmark_tests/security_tests/bm_is_policy_update_allowed.cpp @@ -27,7 +27,12 @@ static void BM_is_policy_update_allowed_valid_uid_no_requests(benchmark::State & std::set its_failed; std::vector policy_elements; std::set input { utility::get_policies_path() + configuration_file }; + std::string test = utility::get_policies_path() + configuration_file; + utility::read_data(input, policy_elements, its_failed); + if (policy_elements.empty()) { + throw std::runtime_error("No valid policies loaded. Check the input files or configurations."+test); + } // Load the configuration into the security. const bool check_whitelist { true }; diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt index af4d723ce..8a1ca5ddd 100644 --- a/test/common/CMakeLists.txt +++ b/test/common/CMakeLists.txt @@ -15,19 +15,22 @@ file (GLOB INC include/common/*.hpp, include/common/vsomeip_app_utilities/*.hpp) # Declare the library # ---------------------------------------------------------------------------- add_library ( - ${PROJECT_NAME} SHARED + vsomeip_utilities ${SRC} ${INC} ) -TARGET_LINK_LIBRARIES ( - ${PROJECT_NAME} +target_link_libraries ( + vsomeip_utilities PUBLIC ${VSOMEIP_NAME} - ${Boost_LIBRARIES} - ${DL_LIBRARY} + PRIVATE + Boost::system + Boost::filesystem ${TEST_LINK_LIBRARIES} ${DLT_LIBRARIES} + INTERFACE + DL_INTERFACE ) # ---------------------------------------------------------------------------- @@ -35,11 +38,12 @@ TARGET_LINK_LIBRARIES ( # by this library # ---------------------------------------------------------------------------- target_include_directories ( - ${PROJECT_NAME} + vsomeip_utilities PUBLIC include PRIVATE src ) +target_compile_definitions(vsomeip_utilities PUBLIC SOURCE_DIR="${CMAKE_SOURCE_DIR}") if (MSVC) - set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif () + set_target_properties(vsomeip_utilities PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() diff --git a/test/common/src/utility.cpp b/test/common/src/utility.cpp index cdf6db8a9..d28fccc40 100644 --- a/test/common/src/utility.cpp +++ b/test/common/src/utility.cpp @@ -95,10 +95,9 @@ utility::get_all_files_in_dir(const std::string &_dir_path, std::string utility::get_policies_path() { - - return boost::filesystem::canonical( - boost::filesystem::current_path()).string() - + "/../test/common/examples_policies"; + std::string source_dir = SOURCE_DIR; + boost::filesystem::path policies_path(source_dir+"/test/common/examples_policies"); + return policies_path.string(); } vsomeip_sec_client_t diff --git a/test/internal_routing_disabled_acceptance_test/CMakeLists.txt b/test/internal_routing_disabled_acceptance_test/CMakeLists.txt index 2c2021fb5..6e3a009a2 100644 --- a/test/internal_routing_disabled_acceptance_test/CMakeLists.txt +++ b/test/internal_routing_disabled_acceptance_test/CMakeLists.txt @@ -7,7 +7,7 @@ endif() project(internal_routing_disabled_acceptance_test LANGUAGES CXX) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wconversion -Wextra") +add_compile_options(-pedantic -Wall -Wconversion -Wextra) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -15,7 +15,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} applet.cpp client.cpp server.cpp main.cpp) target_include_directories(${PROJECT_NAME} PRIVATE ${gtest_SOURCE_DIR}/include) -target_link_libraries(${PROJECT_NAME} PRIVATE gtest Threads::Threads vsomeip3 ${Boost_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE gtest Threads::Threads vsomeip3 Boost::system) if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_compile_definitions(${PROJECT_NAME} PRIVATE _QNX_SOURCE) diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index 1481260dc..f7d60f76d 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -58,7 +58,7 @@ function(targets_link_default_libraries targets) foreach(target ${targets}) target_link_libraries(${target} ${VSOMEIP_NAME} - ${Boost_LIBRARIES} + Boost::system ${DL_LIBRARY} ${TEST_LINK_LIBRARIES} ${DLT_LIBRARIES} diff --git a/test/network_tests/offer_tests/offer_test_client.cpp b/test/network_tests/offer_tests/offer_test_client.cpp index e88b6c8d1..10362058d 100644 --- a/test/network_tests/offer_tests/offer_test_client.cpp +++ b/test/network_tests/offer_tests/offer_test_client.cpp @@ -21,7 +21,7 @@ #ifdef ANDROID #include "../../implementation/configuration/include/internal_android.hpp" #else -#include "../../implementation/configuration/include/internal.hpp" +#include "internal.hpp" #endif // ANDROID #include "offer_test_globals.hpp" diff --git a/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp b/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp index 6fce0156a..18dc7e94c 100644 --- a/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp +++ b/test/network_tests/offered_services_info_tests/offered_services_info_test_client.cpp @@ -22,7 +22,7 @@ #ifdef ANDROID #include "../../implementation/configuration/include/internal_android.hpp" #else -#include "../../implementation/configuration/include/internal.hpp" +#include "internal.hpp" #endif #include "offered_services_info_test_globals.hpp" diff --git a/test/network_tests/offered_services_info_tests/offered_services_info_test_service.cpp b/test/network_tests/offered_services_info_tests/offered_services_info_test_service.cpp index 459455f9f..87762d97c 100644 --- a/test/network_tests/offered_services_info_tests/offered_services_info_test_service.cpp +++ b/test/network_tests/offered_services_info_tests/offered_services_info_test_service.cpp @@ -22,7 +22,7 @@ #ifdef ANDROID #include "../../implementation/configuration/include/internal_android.hpp" #else -#include "../../implementation/configuration/include/internal.hpp" +#include "internal.hpp" #endif // ANDROID #include "offered_services_info_test_globals.hpp" diff --git a/test/unit_tests/message_deserializer_tests/CMakeLists.txt b/test/unit_tests/message_deserializer_tests/CMakeLists.txt index caebfe9da..ddccae4f2 100644 --- a/test/unit_tests/message_deserializer_tests/CMakeLists.txt +++ b/test/unit_tests/message_deserializer_tests/CMakeLists.txt @@ -15,10 +15,10 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg Threads::Threads - ${Boost_LIBRARIES} + Boost::system Boost::thread ${DL_LIBRARY} gtest vsomeip_utilities diff --git a/test/unit_tests/message_payload_impl_tests/CMakeLists.txt b/test/unit_tests/message_payload_impl_tests/CMakeLists.txt index aeea25cb2..3d7a3fac5 100644 --- a/test/unit_tests/message_payload_impl_tests/CMakeLists.txt +++ b/test/unit_tests/message_payload_impl_tests/CMakeLists.txt @@ -15,9 +15,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg - ${Boost_LIBRARIES} + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg + Boost::system Boost::thread ${DL_LIBRARY} gtest vsomeip_utilities diff --git a/test/unit_tests/message_serializer_tests/CMakeLists.txt b/test/unit_tests/message_serializer_tests/CMakeLists.txt index 1fdb76c88..a349a73d7 100644 --- a/test/unit_tests/message_serializer_tests/CMakeLists.txt +++ b/test/unit_tests/message_serializer_tests/CMakeLists.txt @@ -15,9 +15,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg - ${Boost_LIBRARIES} + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg + Boost::system Boost::thread ${DL_LIBRARY} gtest vsomeip_utilities diff --git a/test/unit_tests/protocol_tests/CMakeLists.txt b/test/unit_tests/protocol_tests/CMakeLists.txt index 0bb739dbe..bd61c8ef0 100644 --- a/test/unit_tests/protocol_tests/CMakeLists.txt +++ b/test/unit_tests/protocol_tests/CMakeLists.txt @@ -24,6 +24,7 @@ add_executable( target_link_libraries( ${PROJECT_NAME} gtest + ${VSOMEIP_NAME} ) add_dependencies(build_unit_tests ${PROJECT_NAME}) diff --git a/test/unit_tests/routing_manager_tests/CMakeLists.txt b/test/unit_tests/routing_manager_tests/CMakeLists.txt index b650ddbca..783b44f33 100644 --- a/test/unit_tests/routing_manager_tests/CMakeLists.txt +++ b/test/unit_tests/routing_manager_tests/CMakeLists.txt @@ -15,10 +15,10 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg Threads::Threads - ${Boost_LIBRARIES} + Boost::system Boost::thread ${DL_LIBRARY} gtest gmock diff --git a/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt b/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt index 9c864e80d..48f52a8e0 100644 --- a/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt +++ b/test/unit_tests/security_policy_manager_impl_tests/CMakeLists.txt @@ -15,9 +15,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg - ${Boost_LIBRARIES} + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg + Boost::system Boost::thread ${DL_LIBRARY} gtest vsomeip_utilities diff --git a/test/unit_tests/security_policy_tests/CMakeLists.txt b/test/unit_tests/security_policy_tests/CMakeLists.txt index a989a39eb..239732fa8 100644 --- a/test/unit_tests/security_policy_tests/CMakeLists.txt +++ b/test/unit_tests/security_policy_tests/CMakeLists.txt @@ -15,9 +15,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg - ${Boost_LIBRARIES} + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg + Boost::system Boost::thread ${DL_LIBRARY} gtest vsomeip_utilities diff --git a/test/unit_tests/security_tests/CMakeLists.txt b/test/unit_tests/security_tests/CMakeLists.txt index cc03debf7..bc82d8145 100644 --- a/test/unit_tests/security_tests/CMakeLists.txt +++ b/test/unit_tests/security_tests/CMakeLists.txt @@ -15,10 +15,10 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg Threads::Threads - ${Boost_LIBRARIES} + Boost::system Boost::thread ${DL_LIBRARY} gtest vsomeip_utilities diff --git a/test/unit_tests/utility_utility_tests/CMakeLists.txt b/test/unit_tests/utility_utility_tests/CMakeLists.txt index 9f37c2a89..32ac3b291 100644 --- a/test/unit_tests/utility_utility_tests/CMakeLists.txt +++ b/test/unit_tests/utility_utility_tests/CMakeLists.txt @@ -15,9 +15,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries( ${PROJECT_NAME} - vsomeip3 - vsomeip3-cfg - ${Boost_LIBRARIES} + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-cfg + Boost::system Boost::thread ${DL_LIBRARY} gtest vsomeip_utilities diff --git a/tools/vsomeip_ctrl/CMakeLists.txt b/tools/vsomeip_ctrl/CMakeLists.txt index 39dcd39a9..f779368c8 100644 --- a/tools/vsomeip_ctrl/CMakeLists.txt +++ b/tools/vsomeip_ctrl/CMakeLists.txt @@ -1,22 +1,22 @@ -# Copyright (C) 2016-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/. +# Copyright (C) 2016-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.13) # vsomeip_ctrl -add_executable(vsomeip_ctrl EXCLUDE_FROM_ALL vsomeip_ctrl.cpp) -target_link_libraries(vsomeip_ctrl - vsomeip3 - ${Boost_LIBRARIES} - ${DL_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} +add_executable(vsomeip_ctrl EXCLUDE_FROM_ALL) +target_sources(vsomeip_ctrl PRIVATE vsomeip_ctrl.cpp) +target_link_libraries( + vsomeip_ctrl + PUBLIC ${VSOMEIP_NAME} + PRIVATE Boost::filesystem DL_INTERFACE Threads::Threads ) add_dependencies(tools vsomeip_ctrl) -install ( - TARGETS vsomeip_ctrl - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin OPTIONAL +install( + TARGETS vsomeip_ctrl RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT bin + OPTIONAL ) - -################################################################################################### -