Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1516 Use Googletest detection in all components
Browse files Browse the repository at this point in the history
Signed-off-by: Dietrich Krönke <[email protected]>
  • Loading branch information
dkroenke committed Aug 3, 2022
1 parent d7bbc05 commit 0fb3b51
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 34 deletions.
16 changes: 8 additions & 8 deletions doc/aspice_swe3_4/example/iceoryx_component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,16 @@ iox_add_library(
########## test ##########
#

if(BUILD_TEST AND NOT GTest_FOUND)
find_package(GTest CONFIG REQUIRED)
endif(BUILD_TEST AND NOT GTest_FOUND)
if(BUILD_TEST)
detect_gtest_package()

set(PROJECT_PREFIX "iceoryx_component")
set(PROJECT_PREFIX "iceoryx_component")

file(GLOB_RECURSE MODULETESTS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/test/moduletests/*.cpp")
file(GLOB_RECURSE MODULETESTS_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/test/moduletests/*.cpp")

set(TEST_LINK_LIBS
GTest::gtest
GTest::gmock
set(TEST_LINK_LIBS
${IOX_GTEST_LIBS}
iceoryx_component::iceoryx_component
)

Expand All @@ -64,3 +63,4 @@ iox_add_executable(
LIBS ${TEST_LINK_LIBS}
LIBS_LINUX dl
)
endif()
1 change: 1 addition & 0 deletions iceoryx_binding_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ iox_add_library(
########## build test executables ##########
#
if(BUILD_TEST)
detect_gtest_package()
add_subdirectory(test)
endif()
4 changes: 1 addition & 3 deletions iceoryx_binding_c/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ project(test_binding_c VERSION 0)

find_package(iceoryx_hoofs_testing REQUIRED)
find_package(iceoryx_posh_testing REQUIRED)
find_package(GTest CONFIG REQUIRED)

set(PROJECT_PREFIX "binding_c")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_PREFIX}/test)
Expand All @@ -28,8 +27,7 @@ file(GLOB_RECURSE MODULETESTS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/moduletests/*.cpp

set(TEST_LINK_LIBS
${CODE_COVERAGE_LIBS}
GTest::gtest
GTest::gmock
${IOX_GTEST_LIBS}
iceoryx_binding_c::iceoryx_binding_c
iceoryx_hoofs::iceoryx_hoofs
iceoryx_hoofs_testing::iceoryx_hoofs_testing
Expand Down
1 change: 1 addition & 0 deletions iceoryx_dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ iox_add_executable(
########## build test executables ##########
#
if(BUILD_TEST)
detect_gtest_package()
add_subdirectory(test)
endif()
4 changes: 1 addition & 3 deletions iceoryx_dds/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ project(test_iox_to_dds VERSION 0)

find_package(iceoryx_hoofs_testing REQUIRED)
find_package(iceoryx_posh_testing REQUIRED)
find_package(GTest CONFIG REQUIRED)

set(PROJECT_PREFIX "dds_gateway")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_PREFIX}/test)
Expand All @@ -28,8 +27,7 @@ file(GLOB_RECURSE MODULETESTS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/moduletests/*.cpp

set(TEST_LINK_LIBS
${CODE_COVERAGE_LIBS}
GTest::gtest
GTest::gmock
${IOX_GTEST_LIBS}
iceoryx_hoofs::iceoryx_hoofs
iceoryx_hoofs_testing::iceoryx_hoofs_testing
iceoryx_posh::iceoryx_posh
Expand Down
14 changes: 4 additions & 10 deletions iceoryx_hoofs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,12 @@ iox_add_library(
########## hoofs testing ##########
#

# Finding gtest and adding the subdirectories is split to support the use case of
# building the testing lib without the tests by providing gtest externally
if(NOT GTest_FOUND AND BUILD_TEST)
find_package(GTest CONFIG REQUIRED)
endif()

if(GTest_FOUND)
message(STATUS "GTest was found, building iceoryx_hoofs_testing enabled.")

if(BUILD_TEST)
detect_gtest_package()
add_subdirectory(testing)
if(BUILD_TEST)
add_subdirectory(test)
endif()
add_subdirectory(test)
endif()

install(
Expand Down
3 changes: 1 addition & 2 deletions iceoryx_hoofs/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_PREFIX}/test)

set(TEST_LINK_LIBS
${CODE_COVERAGE_LIBS}
GTest::gtest
GTest::gmock
${IOX_GTEST_LIBS}
iceoryx_hoofs::iceoryx_hoofs
iceoryx_hoofs_testing::iceoryx_hoofs_testing
)
Expand Down
5 changes: 3 additions & 2 deletions iceoryx_hoofs/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
iox_add_library(
STATIC
TARGET ${PROJECT_NAME}_testing
${IOX_GTEST_GMOCK_INCLUDE}
NAMESPACE iceoryx_hoofs_testing
PROJECT_PREFIX ${PREFIX}
PUBLIC_LIBS GTest::gtest
GTest::gmock
PUBLIC_LIBS ${IOX_GTEST_LIBS}
PRIVATE_LIBS ${CODE_COVERAGE_LIBS}
iceoryx_hoofs
${CMAKE_DL_LIBS}
PRIVATE_LIBS_LINUX rt
BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include
INSTALL_INTERFACE include/${PREFIX}
${IOX_EXPORT_GTEST_LIBS}
FILES
mocks/time_mock.cpp
mocks/error_handler_mock.cpp
Expand Down
7 changes: 1 addition & 6 deletions iceoryx_posh/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ find_package(iceoryx_posh_testing REQUIRED)

set(ICEORYX_POSH_TEST_STACK_SIZE 5000000)

if(BUILD_TEST AND NOT GTest_FOUND)
find_package(GTest CONFIG REQUIRED)
endif(BUILD_TEST AND NOT GTest_FOUND)

set(PROJECT_PREFIX "posh")

# Set path for input files in test
Expand All @@ -46,8 +42,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_PREFIX}/test)

set(TEST_LINK_LIBS
${CODE_COVERAGE_LIBS}
GTest::gtest
GTest::gmock
${IOX_GTEST_LIBS}
iceoryx_hoofs::iceoryx_hoofs
iceoryx_hoofs::iceoryx_platform
iceoryx_hoofs_testing::iceoryx_hoofs_testing
Expand Down

0 comments on commit 0fb3b51

Please sign in to comment.