2026-03-27 14:12:49 +01:00
#*******************************************************************************
# Copyright (c) 2025-2026 ZF Friedrichshafen AG
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#*******************************************************************************
2025-11-04 13:28:06 +01:00
project ( SystemDemoExample )
# Use new policy for project version settings and default warning level
cmake_policy ( SET CMP0048 NEW ) # requires CMake 3.14
cmake_policy ( SET CMP0092 NEW ) # requires CMake 3.15
set ( CMAKE_CXX_STANDARD 17 )
# Libary symbols are hidden by default
set ( CMAKE_CXX_VISIBILITY_PRESET hidden )
# Include directory to the core framework
include_directories ( ${ SDV_FRAMEWORK_DEV_INCLUDE } )
######################################################################################################################################################################
# preparation
######################################################################################################################################################################
# REMARK: The code generation for the proxy/stub, interface definitions and serialization, the vehicle devices and the basic
# services are generated during the configuration phase of CMake. This is necessary, since CMakeFiles.txt files are generated and
# they have to be available during the configuration phase of CMake to be taken into the build process. Requisite for the code
# generation during the configuration time of CMake is the availability of the tools to do the generation. Hence the tools cannot be
# created during the build process, which is executed after the configuraiton process.
# Execute sdv_vss_util to create IDL files for devices and basic services.
message ( "Create interface code for devices and basic services of open trunk example." )
execute_process ( COMMAND "${SDV_VSS_UTIL}" "${PROJECT_SOURCE_DIR}/vss_open_trunk_example.csv" "-O${PROJECT_SOURCE_DIR}/generated/" --prefixtrunk --version1.0.0.1 --enable_components )
# Execute the IDL compiler for the VSS interfaces to digest interface code. Compile with --no_ps as we do not need proxies and stubs as we do not like to expose these interfaces for complex services or applications
message ( "Compiling vss_vehiclebodytrunk_vd_tx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclebodytrunk_vd_tx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --no_ps )
message ( "Compiling vss_vehiclespeed_vd_rx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclespeed_vd_rx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --no_ps )
# We need proxies and stubs for basic services to give access to the interfaces for complex services ans applications: --ps_lib_namedemo_proxystub
message ( "Compiling vss_vehiclebodytrunk_bs_tx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclebodytrunk_bs_tx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --ps_lib_nametrunk_proxystub )
message ( "Compiling vss_vehiclespeed_bs_rx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclespeed_bs_rx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --ps_lib_nametrunk_proxystub )
# Execute sdv_dbc_util to create data link code & FMU code.
message ( "Create data link for open trunk example" )
execute_process ( COMMAND ${ SDV_DBC_UTIL } "${PROJECT_SOURCE_DIR}/open_trunk_example.dbc" "-O${PROJECT_SOURCE_DIR}/generated/" --nodestrunk --version1.0.0.1 --moduleTrunkExampleFMU --dl_lib_namecan_dl_trunk )
# Execute the IDL compiler for the complex service to digest interface code.
message ( "Compiling trunkkit.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/trunk_service/trunkkit.idl" "-O${PROJECT_SOURCE_DIR}/generated/trunk_service/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Itrunk_service/ --ps_lib_nametrunk_service_proxystub )
######################################################################################################################################################################
# data link component
######################################################################################################################################################################
# REMARK: CAN data link code was generated during the configuration phase of CMake. Following below is the build step to build the
# component that was generated.
message ( "Include: example component can_dl_trunk" )
add_subdirectory ( generated/can_dl )
#######################################################################################################################################################################
## vehicle devices and basic services
#######################################################################################################################################################################
# REMARK: Proxy/stub and vehicle device and basic service code was generated during the configuration phase of CMake. Following
# below are the build steps to build the components that were generated.
message ( "Include: trunk proxy/stub for vehicle devices and basic services" )
include_directories ( ${ CMAKE_CURRENT_LIST_DIR } /generated/vss_files )
add_subdirectory ( generated/vss_files/ps )
add_subdirectory ( generated/vss_files/vd_vehicletrunk )
add_subdirectory ( generated/vss_files/vd_vehiclespeed )
add_subdirectory ( generated/vss_files/bs_vehicletrunk )
add_subdirectory ( generated/vss_files/bs_vehiclespeed )
######################################################################################################################################################################
# complex service
######################################################################################################################################################################
message ( "Include: proxy/stub for complex trunk service" )
include_directories ( ${ CMAKE_CURRENT_LIST_DIR } /generated/trunk_service )
add_subdirectory ( generated/trunk_service/ps )
message ( "Include: example component trunk_complex_service" )
add_library ( trunk_complex_service SHARED
t r u n k _ s e r v i c e / c o m p l e x _ s e r v i c e . h
t r u n k _ s e r v i c e / c o m p l e x _ s e r v i c e . c p p
)
set_target_properties ( trunk_complex_service PROPERTIES OUTPUT_NAME "trunk_complex_service" )
set_target_properties ( trunk_complex_service PROPERTIES PREFIX "" )
set_target_properties ( trunk_complex_service PROPERTIES SUFFIX ".sdv" )
######################################################################################################################################################################
2026-03-27 14:12:49 +01:00
# open trunk application
2025-11-04 13:28:06 +01:00
######################################################################################################################################################################
# Define the executable
add_executable ( open_trunk_example
o p e n _ t r u n k _ a p p / t r u n k _ e x a m p l e . c p p
o p e n _ t r u n k _ a p p / t r u n k _ a p p l i c a t i o n . c p p
o p e n _ t r u n k _ a p p / t r u n k _ a p p l i c a t i o n . h
o p e n _ t r u n k _ a p p / c o n s o l e . c p p
o p e n _ t r u n k _ a p p / c o n s o l e . h
o p e n _ t r u n k _ a p p / s i g n a l _ n a m e s . h
)
if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
if ( WIN32 )
target_link_libraries ( open_trunk_example Ws2_32 Winmm Rpcrt4.lib )
else ( )
target_link_libraries ( open_trunk_example ${ CMAKE_DL_LIBS } rt ${ CMAKE_THREAD_LIBS_INIT } )
endif ( )
else ( )
target_link_libraries ( open_trunk_example Rpcrt4.lib )
endif ( )
# Copy the config files
file ( COPY ${ PROJECT_SOURCE_DIR } /config/can_com_simulation_trunk.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/complex_service_trunk.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/data_dispatch_trunk.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/data_link_trunk.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/task_timer_trunk.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/trunk_vehicle_device_and_basic_service.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
# Copy the ASC files used by can_com_sim.sdv which includes the CAN messages
# Required in both locations when running standalone or as instance
file ( COPY ${ PROJECT_SOURCE_DIR } /open_trunk_receiver.asc DESTINATION ${ CMAKE_BINARY_DIR } /bin )
file ( COPY ${ PROJECT_SOURCE_DIR } /open_trunk_receiver.asc DESTINATION ${ CMAKE_BINARY_DIR } ../../bin )
######################################################################################################################################################################
# create instance 3005 of system trunk application
######################################################################################################################################################################
# REMARK: Currently the "sdv_packager" tool takes the created component(s), creates a configuration and installation manifest and
# copies the package including manifest and configuration to the runtime installation directory (SDV_FRAMEWORK_RUNTIME
# environment variable with instance #3001). The copying into the target directory is not the wanted installation procedure and only
# a bypass feature of the packager. The proper installation would be creating a installation package with the packager, uploading
# the package to the target system and installing the package using the "sdv_control" tool. Since the creation and installation of
# packages is not available yet, the bypass solution is the only solution available at the moment.
add_custom_target ( trunk_interface_config
A L L
D E P E N D S
c a n _ d l _ t r u n k
t r u n k _ v d _ v e h i c l e s p e e d _ r x
t r u n k _ v d _ v e h i c l e t r u n k _ t x
C O M M A N D " $ { S D V _ P A C K A G E R } " D I R E C T _ I N S T A L L E x a m p l e I n t e r f a c e C o m p o n e n t s - - i n s t a n c e 3 0 0 5 c a n _ d l _ t r u n k . s d v t r u n k _ v d _ v e h i c l e s p e e d _ r x . s d v t r u n k _ v d _ v e h i c l e t r u n k _ t x . s d v " - I $ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } " - - i n t e r f a c e _ c o n f i g - - o v e r w r i t e
V E R B A T I M
)
add_custom_target ( trunk_abstract_config
A L L
D E P E N D S
t r u n k _ p r o x y s t u b
t r u n k _ b s _ v e h i c l e s p e e d _ r x
t r u n k _ b s _ v e h i c l e t r u n k _ t x
C O M M A N D " $ { S D V _ P A C K A G E R } " D I R E C T _ I N S T A L L E x a m p l e A b s t r a c t C o m p o n e n t s - - i n s t a n c e 3 0 0 5 t r u n k _ p r o x y s t u b . s d v t r u n k _ b s _ v e h i c l e s p e e d _ r x . s d v t r u n k _ b s _ v e h i c l e t r u n k _ t x . s d v " - I $ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } " - - a b s t r a c t _ c o n f i g - - o v e r w r i t e
V E R B A T I M
)
add_custom_target ( trunk_user_config
A L L
D E P E N D S
t r u n k _ c o m p l e x _ s e r v i c e
t r u n k _ s e r v i c e _ p r o x y s t u b
C O M M A N D " $ { S D V _ P A C K A G E R } " D I R E C T _ I N S T A L L T r u n k A p p l i c a t i o n - - i n s t a n c e 3 0 0 5 t r u n k _ c o m p l e x _ s e r v i c e . s d v t r u n k _ s e r v i c e _ p r o x y s t u b . s d v " - I $ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } " - - u s e r _ c o n f i g - - o v e r w r i t e
V E R B A T I M
)
2026-03-27 14:12:49 +01:00
add_custom_target ( trunk_platform_config
A L L
C O M M A N D " $ { S D V _ P A C K A G E R } " C O N F I G U R E $ { P R O J E C T _ S O U R C E _ D I R } / c o r e c o n f i g / p l a t f o r m . t o m l - - i n s t a n c e 3 0 0 5 - - p l a t f o r m _ c o n f i g
V E R B A T I M
)
2025-11-04 13:28:06 +01:00