Skip to content

Commit

Permalink
Updating Hello World example CMakeLists
Browse files Browse the repository at this point in the history
Co-authored-by: "Duarte Fonseca" <Duarte.Fonseca@ctw.bmwgroup.com>
Co-authored-by: "Matthew Russell" <matthew.g.russell@gmail.com>
  • Loading branch information
Duarte Fonseca and kheaactua committed Oct 3, 2024
1 parent f3cabc5 commit 0c2f5f9
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions examples/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,33 +24,32 @@ 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")
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()

0 comments on commit 0c2f5f9

Please sign in to comment.