Skip to content

Commit b45251e

Browse files
Duarte Fonsecakheaactua
Duarte Fonseca
andcommitted
Updating Hello World example CMakeLists
Co-authored-by: "Duarte Fonseca" <[email protected]> Co-authored-by: "Matthew Russell" <[email protected]>
1 parent 6948488 commit b45251e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

examples/hello_world/CMakeLists.txt

+17-13
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
cmake_minimum_required (VERSION 3.13)
77
project (vSomeIPHelloWorld)
88

9+
include(GNUInstallDirs)
10+
911
find_package(Threads REQUIRED)
1012

11-
include(GNUInstallDirs)
13+
# This will get us acces to
14+
# VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP
15+
# VSOMEIP_LIBRARIES - libraries to link against
16+
find_package(vsomeip3 REQUIRED)
1217

1318
# create_target("executable")
1419
function(create_target executable)
@@ -19,33 +24,32 @@ function(create_target executable)
1924
target_compile_features(vsomeip_hello_world_${executable} INTERFACE cxx_std_17)
2025

2126
target_include_directories(vsomeip_hello_world_${executable} INTERFACE
22-
${CMAKE_CURRENT_SOURCE_DIR}
27+
${PROJECT_SOURCE_DIR}
2328
)
24-
25-
if(ENABLE_SIGNAL_HANDLING)
26-
target_compile_definitions(vsomeip_hello_world_example INTERFACE VSOMEIP_ENABLE_SIGNAL_HANDLING)
27-
endif()
2829
endfunction()
2930

3031
# link_target("executable")
3132
function(link_target executable)
3233
add_executable(hello_world_${executable})
3334
target_sources(hello_world_${executable} PRIVATE hello_world_${executable}_main.cpp)
3435
target_link_libraries(hello_world_${executable} PRIVATE vsomeip_hello_world_${executable} vsomeip3 Threads::Threads)
36+
if(ENABLE_SIGNAL_HANDLING)
37+
target_compile_definitions(vsomeip_hello_world_${executable} PRIVATE VSOMEIP_ENABLE_SIGNAL_HANDLING)
38+
endif()
3539
endfunction()
3640

3741
create_target("service")
3842
create_target("client")
3943

4044
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
41-
# This will get us acces to
42-
# VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP
43-
# VSOMEIP_LIBRARIES - libraries to link against
44-
find_package(${VSOMEIP_NAME})
45-
if (NOT ${VSOMEIP_NAME}_FOUND)
46-
message("${VSOMEIP_NAME} was not found. Please specify vsomeip_DIR")
47-
endif()
4845

4946
link_target("client")
5047
link_target("service")
48+
49+
install(
50+
TARGETS
51+
hello_world_client hello_world_service RUNTIME
52+
DESTINATION "${INSTALL_BIN_DIR}"
53+
COMPONENT example-hello_world
54+
)
5155
endif()

0 commit comments

Comments
 (0)