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 demo example." )
execute_process ( COMMAND "${SDV_VSS_UTIL}" "${PROJECT_SOURCE_DIR}/vss_demo_example.csv" "-O${PROJECT_SOURCE_DIR}/generated/" --prefixdemo --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_vehiclechassisrearaxlerowwheel_vd_tx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclechassisrearaxlerowwheel_vd_tx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --no_ps )
message ( "Compiling vss_vehiclechassissteeringwheelangle_vd_rx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclechassissteeringwheelangle_vd_rx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --no_ps )
message ( "Compiling vss_vehiclesoftwareapplicationisactivecounter_vd_tx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclesoftwareapplicationisactivecounter_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_vehiclechassisrearaxlerowwheel_bs_tx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclechassisrearaxlerowwheel_bs_tx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --ps_lib_namedemo_proxystub )
message ( "Compiling vss_vehiclechassissteeringwheelangle_bs_rx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclechassissteeringwheelangle_bs_rx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --ps_lib_namedemo_proxystub )
message ( "Compiling vss_vehiclesoftwareapplicationisactivecounter_bs_tx.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclesoftwareapplicationisactivecounter_bs_tx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --ps_lib_namedemo_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_namedemo_proxystub )
# Execute sdv_dbc_util to create data link code & FMU code.
message ( "Create functional mockup unit (FMU) of demo example." )
execute_process ( COMMAND ${ SDV_DBC_UTIL } "${PROJECT_SOURCE_DIR}/datalink_demo_example.dbc" "-O${PROJECT_SOURCE_DIR}/generated/" --nodesdemo --version1.0.0.1 --moduleDemoExampleFMU --dl_lib_namecan_dl_example )
# Execute the IDL compiler for the complex service to digest interface code.
message ( "Compiling countersteering.idl" )
execute_process ( COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/example_service/countersteering.idl" "-O${PROJECT_SOURCE_DIR}/generated/example_service/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Iexample_service/ --ps_lib_nameexample_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_example" )
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: demo 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_isactivecounter )
add_subdirectory ( generated/vss_files/vd_vehiclechassisaxle )
add_subdirectory ( generated/vss_files/vd_steeringwheel )
add_subdirectory ( generated/vss_files/vd_vehiclespeed )
add_subdirectory ( generated/vss_files/bs_isactivecounter )
add_subdirectory ( generated/vss_files/bs_vehiclechassisaxle )
add_subdirectory ( generated/vss_files/bs_steeringwheel )
add_subdirectory ( generated/vss_files/bs_vehiclespeed )
######################################################################################################################################################################
# complex service
######################################################################################################################################################################
message ( "Include: proxy/stub for complex example service" )
include_directories ( ${ CMAKE_CURRENT_LIST_DIR } /generated/example_service )
add_subdirectory ( generated/example_service/ps )
message ( "Include: example component demo_complex_service" )
add_library ( demo_complex_service SHARED
e x a m p l e _ s e r v i c e / c o m p l e x _ s e r v i c e . h
e x a m p l e _ 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 ( demo_complex_service PROPERTIES OUTPUT_NAME "demo_complex_service" )
set_target_properties ( demo_complex_service PROPERTIES PREFIX "" )
set_target_properties ( demo_complex_service PROPERTIES SUFFIX ".sdv" )
######################################################################################################################################################################
# basic_system demo application
######################################################################################################################################################################
# Define the executable
add_executable ( system_extern_example
e x a m p l e _ a p p / s y s t e m _ e x t e r n _ e x a m p l e . c p p
e x a m p l e _ 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 ( system_extern_example Ws2_32 Winmm Rpcrt4.lib )
else ( )
target_link_libraries ( system_extern_example ${ CMAKE_DL_LIBS } rt ${ CMAKE_THREAD_LIBS_INIT } )
endif ( )
else ( )
target_link_libraries ( system_extern_example Rpcrt4.lib )
endif ( )
######################################################################################################################################################################
# system demo application
######################################################################################################################################################################
# Define the executable
add_executable ( system_demo_example
e x a m p l e _ a p p / s y s t e m _ d e m o _ e x a m p l e . c p p
e x a m p l e _ a p p / c o n t r o l . h
e x a m p l e _ a p p / c o n t r o l . c p p
e x a m p l e _ a p p / c o n s o l e . h
e x a m p l e _ a p p / c o n s o l e . c p p
e x a m p l e _ 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 ( system_demo_example Ws2_32 Winmm Rpcrt4.lib )
else ( )
target_link_libraries ( system_demo_example ${ CMAKE_DL_LIBS } rt ${ CMAKE_THREAD_LIBS_INIT } )
endif ( )
else ( )
target_link_libraries ( system_demo_example Rpcrt4.lib )
endif ( )
# Copy the config files
file ( COPY ${ PROJECT_SOURCE_DIR } /config/can_com_simulation.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/data_link_example.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/data_dispatch_example.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/task_timer_example.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/vehicle_devices_basic_services_example.toml DESTINATION ${ CMAKE_BINARY_DIR } /bin/config )
file ( COPY ${ PROJECT_SOURCE_DIR } /config/complex_service_example.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 } /system_demo_receiver.asc DESTINATION ${ CMAKE_BINARY_DIR } /bin )
file ( COPY ${ PROJECT_SOURCE_DIR } /system_demo_receiver.asc DESTINATION ${ CMAKE_BINARY_DIR } ../../bin )
######################################################################################################################################################################
# create instance 3001 of system demo 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 ( example_interface_config
A L L
D E P E N D S
c a n _ d l _ e x a m p l e
d e m o _ v d _ i s a c t i v e c o u n t e r _ t x
d e m o _ v d _ s t e e r i n g w h e e l _ r x
d e m o _ v d _ v e h i c l e c h a s s i s a x l e _ t x
d e m o _ v d _ v e h i c l e s p e e d _ r 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 1 c a n _ d l _ e x a m p l e . s d v d e m o _ v d _ i s a c t i v e c o u n t e r _ t x . s d v d e m o _ v d _ s t e e r i n g w h e e l _ r x . s d v d e m o _ v d _ v e h i c l e c h a s s i s a x l e _ t x . s d v d e m o _ v d _ v e h i c l e s p e e d _ r 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 ( example_abstract_config
A L L
D E P E N D S
d e m o _ p r o x y s t u b
d e m o _ b s _ i s a c t i v e c o u n t e r _ t x
d e m o _ b s _ s t e e r i n g w h e e l _ r x
d e m o _ b s _ v e h i c l e c h a s s i s a x l e _ t x
d e m o _ b s _ v e h i c l e s p e e d _ r 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 1 d e m o _ p r o x y s t u b . s d v d e m o _ b s _ i s a c t i v e c o u n t e r _ t x . s d v d e m o _ b s _ s t e e r i n g w h e e l _ r x . s d v d e m o _ b s _ v e h i c l e c h a s s i s a x l e _ t x . s d v d e m o _ b s _ v e h i c l e s p e e d _ r 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 ( example_user_config
A L L
D E P E N D S
d e m o _ c o m p l e x _ s e r v i c e
e x a m p l e _ 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 D e m o A p p l i c a t i o n - - i n s t a n c e 3 0 0 1 d e m o _ c o m p l e x _ s e r v i c e . s d v e x a m p l e _ 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 ( example_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 1 - - 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
######################################################################################################################################################################
# system demo fmu for OpenXilEnv
######################################################################################################################################################################
# REMARK: The CMAKE created by sdv_dbc_util creates all files including the buildDescription.xml
#
# What cannot be created automatically is the method OpenAPILoad(const std::string& resources) in file model.cpp
# The method must load all required components
2026-03-27 14:12:49 +01:00
# Therefore here the file is copied and overwritten the auto generated file
2025-11-04 13:28:06 +01:00
#
# The required toml files need to be copied to the folder:
# generated/fmu_DemoExampleFMU/DemoExampleFMU/resources
message ( "Include: FMU DemoExampleFMU" )
# Copy the config files
file ( COPY ${ PROJECT_SOURCE_DIR } /fmu/resources/fmu_vehicle_devices_basic_services.toml DESTINATION ${ PROJECT_SOURCE_DIR } /generated/fmu_DemoExampleFMU/DemoExampleFMU/resources )
file ( COPY ${ PROJECT_SOURCE_DIR } /fmu/resources/fmu_complex_service.toml DESTINATION ${ PROJECT_SOURCE_DIR } /generated/fmu_DemoExampleFMU/DemoExampleFMU/resources )
# Overwrite model.cpp with an identical file but loads all components in OpenAPILoad(const std::string& resources)
file ( COPY ${ PROJECT_SOURCE_DIR } /fmu/model.cpp DESTINATION ${ PROJECT_SOURCE_DIR } /generated/fmu_DemoExampleFMU/DemoExampleFMU )
# Now the project can be build
add_subdirectory ( generated/fmu_DemoExampleFMU )