Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Hello World example CMakeLists #752

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions examples/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@ find_package(Threads REQUIRED)

duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
set(VSOMEIP_NAME "vsomeip3")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
# create_target("executable")
function(create_target executable)
add_library(vsomeip_hello_world_${executable} INTERFACE)
target_sources(vsomeip_hello_world_${executable} INTERFACE
duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
"${CMAKE_CURRENT_SOURCE_DIR}/hello_world_${executable}.hpp"
)
target_compile_features(vsomeip_hello_world_${executable} INTERFACE cxx_std_17)

target_include_directories(vsomeip_hello_world_${executable} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}"
duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
)
endfunction()

# link_target("executable")
function(link_target executable)
add_executable (hello_world_${executable} hello_world_${executable}_main.cpp)
duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(hello_world_${executable} vsomeip_hello_world_${executable} ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
duartenfonseca marked this conversation as resolved.
Show resolved Hide resolved
endfunction()

include_directories(${VSOMEIP_INCLUDE_DIRS})

add_library(vsomeip_hello_world_service INTERFACE)
target_sources(vsomeip_hello_world_service INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/hello_world_service.hpp"
)
target_include_directories(vsomeip_hello_world_service INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}"
)

add_library(vsomeip_hello_world_client INTERFACE)
target_sources(vsomeip_hello_world_client INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/hello_world_client.hpp"
)

target_include_directories(vsomeip_hello_world_client INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}"
)
create_target("service")
create_target("client")

if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
# This will get us acces to
Expand All @@ -40,9 +43,6 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
message("${VSOMEIP_NAME} was not found. Please specify vsomeip_DIR")
endif()

add_executable (hello_world_service hello_world_service_main.cpp)
target_link_libraries(hello_world_service vsomeip_hello_world_service ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

add_executable (hello_world_client hello_world_client_main.cpp)
target_link_libraries(hello_world_client vsomeip_hello_world_client ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
link_target("client")
link_target("service")
endif()
Loading