From e2c4cdc6fe5cb4700eeb36840d4b5c18e01028fb Mon Sep 17 00:00:00 2001 From: Duarte Fonseca Date: Mon, 12 Aug 2024 11:39:36 +0100 Subject: [PATCH] Updating Hello World example CMakeLists Co-authored-by: "Duarte Fonseca" Co-authored-by: "Matthew Russell" --- examples/hello_world/CMakeLists.txt | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index fbb581b5e..bd4bc25d1 100644 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -6,9 +6,14 @@ cmake_minimum_required (VERSION 3.13) project (vSomeIPHelloWorld) +include(GNUInstallDirs) + find_package(Threads REQUIRED) -include(GNUInstallDirs) +# This will get us acces to +# VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP +# VSOMEIP_LIBRARIES - libraries to link against +find_package(vsomeip3 REQUIRED) # create_target("executable") function(create_target executable) @@ -19,12 +24,8 @@ 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} ) - - if(ENABLE_SIGNAL_HANDLING) - target_compile_definitions(vsomeip_hello_world_example INTERFACE VSOMEIP_ENABLE_SIGNAL_HANDLING) - endif() endfunction() # link_target("executable") @@ -32,20 +33,23 @@ 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() create_target("service") create_target("client") if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android") - # This will get us acces to - # VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP - # VSOMEIP_LIBRARIES - libraries to link against - find_package(${VSOMEIP_NAME}) - if (NOT ${VSOMEIP_NAME}_FOUND) - message("${VSOMEIP_NAME} was not found. Please specify vsomeip_DIR") - endif() link_target("client") link_target("service") + + install( + TARGETS + hello_world_client hello_world_service RUNTIME + DESTINATION "${INSTALL_BIN_DIR}" + COMPONENT example-hello_world + ) endif()