6
6
cmake_minimum_required (VERSION 3.13)
7
7
project (vSomeIPHelloWorld)
8
8
9
+ include (GNUInstallDirs)
10
+
9
11
find_package (Threads REQUIRED)
10
12
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)
12
17
13
18
# create_target("executable")
14
19
function (create_target executable)
@@ -19,33 +24,32 @@ function(create_target executable)
19
24
target_compile_features (vsomeip_hello_world_${executable} INTERFACE cxx_std_17)
20
25
21
26
target_include_directories (vsomeip_hello_world_${executable} INTERFACE
22
- ${CMAKE_CURRENT_SOURCE_DIR }
27
+ ${PROJECT_SOURCE_DIR }
23
28
)
24
-
25
- if (ENABLE_SIGNAL_HANDLING)
26
- target_compile_definitions (vsomeip_hello_world_example INTERFACE VSOMEIP_ENABLE_SIGNAL_HANDLING)
27
- endif ()
28
29
endfunction ()
29
30
30
31
# link_target("executable")
31
32
function (link_target executable)
32
33
add_executable (hello_world_${executable} )
33
34
target_sources (hello_world_${executable} PRIVATE hello_world_${executable} _main.cpp)
34
35
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 ()
35
39
endfunction ()
36
40
37
41
create_target("service" )
38
42
create_target("client" )
39
43
40
44
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 ()
48
45
49
46
link_target("client" )
50
47
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
+ )
51
55
endif ()
0 commit comments