Skip to content

Commit

Permalink
squash! General CMakeLists improvements - cmake v2→v3
Browse files Browse the repository at this point in the history
Fixed include to interal.hpp, removed variable target name for main libs, applying OS options better, got tests building
  • Loading branch information
kheaactua committed Aug 14, 2024
1 parent 6cf8955 commit f92cf9b
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 285 deletions.
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# This is only relevant for GCC and causes warnings on Clang
add_link_options(
-Wl,-z,relro,-z,now -Wl,-export-dynamic -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap.gcc
)
target_link_options(OS_INTERFACE INTERFACE -Wl,-z,relro,-z,now -Wl,-export-dynamic -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap.gcc)
endif()
add_link_options(-Wl,--wrap=socket,--wrap=accept,--wrap=open)
target_link_options(OS_INTERFACE INTERFACE -Wl,--wrap=socket,--wrap=accept,--wrap=open)

# force all use of std::mutex and std::recursive_mutex to use runtime init instead of static initialization so mutexes
# can be hooked to enable PI as needed
Expand Down Expand Up @@ -176,8 +174,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "QNX")
-fasynchronous-unwind-tables
-fno-omit-frame-pointer
)
add_link_options(-Wl,-export-dynamic)
add_link_options(-Wl,--wrap=socket,--wrap=accept,--wrap=open)
target_link_options(OS_INTERFACE INTERFACE -Wl,-export-dynamic)
target_link_options(OS_INTERFACE INTERFACE -Wl,--wrap=socket,--wrap=accept,--wrap=open)

target_link_libraries(OS_INTERFACE INTERFACE slog2)

Expand Down Expand Up @@ -354,6 +352,12 @@ if(NOT ENABLE_MULTIPLE_ROUTING_MANAGERS)
DL_INTERFACE
OS_INTERFACE
)
else()
# We don't want this target to only conditionally exist.
add_library(vsomeip3-cfg INTERFACE)
message(STATUS "Multiple routing managers enabled, \"disabling\" the
configuration library. Note that the unittests depend on this library so you
won't likely be able to use the tests in this mode")
endif()

# ######################################################################################################################
Expand Down Expand Up @@ -428,7 +432,7 @@ target_link_libraries(
)

if(NOT WIN32)
target_link_options(${VSOMEIP_NAME} PRIVATE "LINKER:-as-needed")
target_link_options(vsomeip3 PRIVATE "LINKER:-as-needed")
endif()

# ######################################################################################################################
Expand Down
26 changes: 17 additions & 9 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ find_package(benchmark)
##############################################################################
# google test

# remove export symbols from the cxx flags
string(REPLACE "${EXPORTSYMBOLS}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# remove export symbols from the cxx flags. This is messy, but there's no `remove_link_flags` function
get_target_property(os_link_options OS_INTERFACE INTERFACE_LINK_OPTIONS)
foreach(opt IN ITEMS ${os_link_options})
if(opt MATCHES ".*version.script.*.gcc")
list(REMOVE_ITEM os_link_options ${opt})
endif()
endforeach()
unset(opt)
set_target_properties(OS_INTERFACE PROPERTIES INTERFACE_LINK_OPTIONS "${os_link_options}")
unset(os_link_options)

# check for set environment variable
if(${GTEST_ROOT} STREQUAL "n/a")
Expand Down Expand Up @@ -107,19 +115,19 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_dependencies(check build_tests)

add_custom_target(build_network_tests)
add_dependencies(build_network_tests ${VSOMEIP_NAME})
add_dependencies(build_network_tests ${VSOMEIP_NAME}-e2e)
add_dependencies(build_network_tests ${VSOMEIP_NAME}-sd)
add_dependencies(build_network_tests vsomeip3)
add_dependencies(build_network_tests vsomeip3-e2e)
add_dependencies(build_network_tests vsomeip3-sd)
add_dependencies(build_tests build_network_tests)

add_custom_target(build_unit_tests)
add_dependencies(build_unit_tests ${VSOMEIP_NAME})
add_dependencies(build_unit_tests ${VSOMEIP_NAME}-sd)
add_dependencies(build_unit_tests vsomeip3)
add_dependencies(build_unit_tests vsomeip3-sd)
add_dependencies(build_tests build_unit_tests)

add_custom_target(build_benchmark_tests)
add_dependencies(build_benchmark_tests ${VSOMEIP_NAME})
add_dependencies(build_benchmark_tests ${VSOMEIP_NAME}-sd)
add_dependencies(build_benchmark_tests vsomeip3)
add_dependencies(build_benchmark_tests vsomeip3-sd)
add_dependencies(build_tests build_benchmark_tests)

##############################################################################
Expand Down
7 changes: 1 addition & 6 deletions test/benchmark_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ file(

set(THREADS_PREFER_PTHREAD_FLAG ON)

find_package(Threads REQUIRED)
find_package(
Boost 1.65
COMPONENTS filesystem system
REQUIRED
)

# ----------------------------------------------------------------------------
# Executable and libraries to link
Expand All @@ -30,6 +24,7 @@ target_link_libraries(
vsomeip3-benchmark-tests
PRIVATE vsomeip3
vsomeip3-cfg
vsomeip_utilities
Threads::Threads
Boost::filesystem
Boost::system
Expand Down
2 changes: 1 addition & 1 deletion test/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TARGET_LINK_LIBRARIES (
# by this library
# ----------------------------------------------------------------------------
target_include_directories (
${PROJECT_NAME}
vsomeip_utilities
PUBLIC include
PRIVATE src
)
7 changes: 2 additions & 5 deletions test/internal_routing_disabled_acceptance_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ endif()

project(internal_routing_disabled_acceptance_test LANGUAGES CXX)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wconversion -Wextra")
add_compile_options(-pedantic -Wall -Wconversion -Wextra)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(THREADS_PREFER_PTHREAD_FLAG ON)

find_package(Threads REQUIRED)
find_package(Boost 1.55 COMPONENTS system REQUIRED)

add_executable(${PROJECT_NAME} applet.cpp client.cpp server.cpp main.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ${gtest_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE gtest Threads::Threads vsomeip3 ${Boost_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE gtest Threads::Threads vsomeip3 Boost::system)

if (${CMAKE_SYSTEM_NAME} MATCHES "QNX")
target_compile_definitions(${PROJECT_NAME} PRIVATE _QNX_SOURCE)
Expand Down
Loading

0 comments on commit f92cf9b

Please sign in to comment.