Skip to content

Commit

Permalink
Support of googletest using colcon [12009] (#2054)
Browse files Browse the repository at this point in the history
* Refs #11961. New support of googletest using colcon

Signed-off-by: Ricardo González <ricardo@richiware.dev>

* Refs #11961. Fix compilation errors

Signed-off-by: Ricardo González <ricardo@richiware.dev>

* Refs #11961. Fix compilation error

Signed-off-by: Ricardo González <ricardo@richiware.dev>

* Refs #11961. Including asio in a good way

Signed-off-by: Ricardo González <ricardo@richiware.dev>

* Refs #11961. gmock exports gtest

Signed-off-by: Ricardo González <ricardo@richiware.dev>

* Refs #11961. Forget to remove one include_directories

Signed-off-by: Ricardo González <ricardo@richiware.dev>

* Refs #11961. Little change

Signed-off-by: Ricardo González <ricardo@richiware.dev>

* Refs #11961. Fix error

Signed-off-by: Ricardo González <ricardo@richiware.dev>
(cherry picked from commit 4f9f7e9)

# Conflicts:
#	examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt
#	examples/C++/DeadlineQoSExample/CMakeLists.txt
#	test/blackbox/CMakeLists.txt
#	test/communication/CMakeLists.txt
#	test/performance/CMakeLists.txt
#	test/performance/latency/CMakeLists.txt
#	test/performance/throughput/CMakeLists.txt
#	test/performance/video/CMakeLists.txt
#	test/profiling/CMakeLists.txt
#	test/realtime/CMakeLists.txt
#	test/unittest/dds/collections/CMakeLists.txt
#	test/unittest/dds/core/condition/CMakeLists.txt
#	test/unittest/dds/core/entity/CMakeLists.txt
#	test/unittest/dds/publisher/CMakeLists.txt
#	test/unittest/dds/status/CMakeLists.txt
#	test/unittest/dynamic_types/CMakeLists.txt
#	test/unittest/logging/CMakeLists.txt
#	test/unittest/logging/log_macros/CMakeLists.txt
#	test/unittest/rtps/common/CMakeLists.txt
#	test/unittest/rtps/flowcontrol/CMakeLists.txt
#	test/unittest/rtps/network/CMakeLists.txt
#	test/unittest/rtps/persistence/CMakeLists.txt
#	test/unittest/rtps/resources/timedevent/CMakeLists.txt
#	test/unittest/rtps/security/CMakeLists.txt
#	test/unittest/rtps/writer/CMakeLists.txt
#	test/unittest/security/accesscontrol/CMakeLists.txt
#	test/unittest/security/authentication/CMakeLists.txt
#	test/unittest/statistics/dds/CMakeLists.txt
#	test/unittest/statistics/rtps/CMakeLists.txt
#	test/unittest/transport/CMakeLists.txt
#	test/unittest/utils/CMakeLists.txt
#	test/unittest/xmlparser/CMakeLists.txt
#	test/unittest/xtypes/CMakeLists.txt
#	test/xtypes/CMakeLists.txt
  • Loading branch information
richiware authored and mergify-bot committed Mar 22, 2022
1 parent 0670fb9 commit a3acef8
Show file tree
Hide file tree
Showing 49 changed files with 1,436 additions and 429 deletions.
60 changes: 0 additions & 60 deletions cmake/common/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,6 @@

option(GTEST_INDIVIDUAL "Activate the execution of GTest tests" OFF)

macro(check_gtest)
if(NOT GTEST_FOUND)
if(WIN32)
option(EPROSIMA_GTEST "Activate special set of GTEST_ROOT" OFF)
if(EPROSIMA_BUILD)
set(EPROSIMA_GTEST ON)
endif()
endif()

# Find package GTest
if(WIN32 AND EPROSIMA_GTEST)
if(NOT GTEST_ROOT)
set(GTEST_ROOT_ $ENV{GTEST_ROOT})
if(GTEST_ROOT_)
file(TO_CMAKE_PATH "${GTEST_ROOT_}/${MSVC_ARCH}" GTEST_ROOT)
endif()
else()
file(TO_CMAKE_PATH "${GTEST_ROOT}/${MSVC_ARCH}" GTEST_ROOT)
endif()
endif()
find_package(GTest)

if(GTEST_FOUND)
find_package(Threads REQUIRED)
set(GTEST_LIBRARIES ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
set(GTEST_BOTH_LIBRARIES ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
endmacro()

macro(check_gmock)
if(NOT GMOCK_FOUND)
if(WIN32)
option(EPROSIMA_GMOCK "Activate special set of GMOCK_ROOT" OFF)
if(EPROSIMA_BUILD)
set(EPROSIMA_GMOCK ON)
endif()
endif()

# Find package GMock
if(WIN32 AND EPROSIMA_GMOCK)
if(NOT GMOCK_ROOT)
set(GMOCK_ROOT_ $ENV{GMOCK_ROOT})
if(GMOCK_ROOT_)
file(TO_CMAKE_PATH "${GMOCK_ROOT_}/${MSVC_ARCH}" GMOCK_ROOT)
endif()
else()
file(TO_CMAKE_PATH "${GMOCK_ROOT}/${MSVC_ARCH}" GMOCK_ROOT)
endif()
endif()
find_package(GMock)

if(GMOCK_FOUND)
find_package(Threads REQUIRED)
set(GMOCK_LIBRARIES ${GMOCK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
set(GMOCK_BOTH_LIBRARIES ${GMOCK_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
endmacro()

macro(add_gtest)
# Parse arguments
if("${ARGV0}" STREQUAL "NAME")
Expand Down
130 changes: 0 additions & 130 deletions cmake/modules/FindGMock.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions colcon.pkg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fastrtps",
"type": "cmake",
"dependencies" : ["fastcdr", "FOONATHAN_MEMORY", "foonathan_memory_vendor"]
}
"dependencies" : ["fastcdr", "FOONATHAN_MEMORY", "foonathan_memory_vendor", "googletest-distribution"]
}
11 changes: 11 additions & 0 deletions examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ endif()
message(STATUS "Configuring DDSDeadlineQoS example...")
file(GLOB DDS_DEADLINEQOS_EXAMPLE_SOURCES "*.cxx")

<<<<<<< HEAD
add_definitions(
-DBOOST_ASIO_STANDALONE
-DASIO_STANDALONE
Expand All @@ -69,6 +70,16 @@ add_definitions(
include_directories(${ASIO_INCLUDE_DIR})

add_executable(DDSDeadlineQoSExample ${DDS_DEADLINEQOS_EXAMPLE_SOURCES})
=======
add_executable(DDSDeadlineQoSExample ${DDS_DEADLINEQOS_EXAMPLE_SOURCES})
target_compile_definitions(DDSDeadlineQoSExample PRIVATE
BOOST_ASIO_STANDALONE
ASIO_STANDALONE
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
$<$<BOOL:${INTERNAL_DEBUG}>:__INTERNALDEBUG> # Internal debug activated.
)
target_include_directories(DDSDeadlineQoSExample PRIVATE ${Asio_INCLUDE_DIR})
>>>>>>> 4f9f7e98e (Support of googletest using colcon [12009] (#2054))
target_link_libraries(DDSDeadlineQoSExample fastrtps fastcdr foonathan_memory)
if(UNIX)
target_link_libraries(DDSDeadlineQoSExample pthread)
Expand Down
11 changes: 11 additions & 0 deletions examples/C++/DeadlineQoSExample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ endif()
message(STATUS "Configuring DeadlineQoS example...")
file(GLOB DEADLINEQOS_EXAMPLE_SOURCES "*.cxx")

<<<<<<< HEAD
add_definitions(
-DBOOST_ASIO_STANDALONE
-DASIO_STANDALONE
Expand All @@ -69,6 +70,16 @@ add_definitions(
include_directories(${ASIO_INCLUDE_DIR})

add_executable(DeadlineQoSExample ${DEADLINEQOS_EXAMPLE_SOURCES})
=======
add_executable(DeadlineQoSExample ${DEADLINEQOS_EXAMPLE_SOURCES})
target_compile_definitions(DeadlineQoSExample PRIVATE
BOOST_ASIO_STANDALONE
ASIO_STANDALONE
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
$<$<BOOL:${INTERNAL_DEBUG}>:__INTERNALDEBUG> # Internal debug activated.
)
target_include_directories(DeadlineQoSExample PRIVATE ${Asio_INCLUDE_DIR})
>>>>>>> 4f9f7e98e (Support of googletest using colcon [12009] (#2054))
target_link_libraries(DeadlineQoSExample fastrtps fastcdr foonathan_memory)
if(UNIX)
target_link_libraries(DeadlineQoSExample pthread)
Expand Down
9 changes: 5 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake)
check_gtest()
check_gmock()

option(PERFORMANCE_TESTS "Activate the building and execution of performance tests" OFF)
option(SYSTEM_TESTS "Activate the building and execution of system tests" OFF)
option(PROFILING_TESTS "Activate the building and execution of profiling tests" OFF)
Expand All @@ -33,6 +29,11 @@ set(MEMORYCHECK_SUPPRESSIONS_FILE ${MEMORYCHECK_SUPPRESSIONS_FILE_TMP} CACHE FIL
# Testing
###############################################################################
if(EPROSIMA_BUILD_TESTS AND IS_TOP_LEVEL AND NOT EPROSIMA_INSTALLER)
find_package(GTest CONFIG REQUIRED)
if (GTest_FOUND)
include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake)
endif()

add_subdirectory(blackbox)
add_subdirectory(communication)
add_subdirectory(unittest)
Expand Down
30 changes: 18 additions & 12 deletions test/blackbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,24 @@ option(FASTRTPS_API_TESTS "Enable tests using FastRTPS API" ON)
option(FASTDDS_PIM_API_TESTS "Enable tests using FastDDS API" OFF)

if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND)
include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake)
check_gtest()

if(GTEST_FOUND)
if(GTest_FOUND)
if(WIN32)
add_definitions(
-D_WIN32_WINNT=0x0601
-D_CRT_SECURE_NO_WARNINGS
)
endif()

<<<<<<< HEAD
add_definitions(
-DBOOST_ASIO_STANDALONE
-DASIO_STANDALONE
)

include_directories(${ASIO_INCLUDE_DIR})

=======
>>>>>>> 4f9f7e98e (Support of googletest using colcon [12009] (#2054))
###############################################################################
# Unit tests
###############################################################################
Expand All @@ -183,11 +183,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND)
)
add_executable(BlackboxTests_RTPS ${RTPS_BLACKBOXTESTS_SOURCE})
target_compile_definitions(BlackboxTests_RTPS PRIVATE
BOOST_ASIO_STANDALONE
ASIO_STANDALONE
$<$<NOT:$<BOOL:${IS_THIRDPARTY_BOOST_SUPPORTED}>>:FASTDDS_SHM_TRANSPORT_DISABLED> # Do not compile SHM Transport
)
target_include_directories(BlackboxTests_RTPS PRIVATE
${GTEST_INCLUDE_DIRS})
target_link_libraries(BlackboxTests_RTPS fastrtps fastcdr foonathan_memory ${GTEST_LIBRARIES})
${Asio_INCLUDE_DIR})
target_link_libraries(BlackboxTests_RTPS fastrtps fastcdr foonathan_memory GTest::gtest)
add_blackbox_gtest(BlackboxTests_RTPS SOURCES ${RTPS_BLACKBOXTESTS_TEST_SOURCE})

file(GLOB BLACKBOXTESTS_TEST_SOURCE "common/BlackboxTests*.cpp")
Expand Down Expand Up @@ -249,12 +251,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND)

add_executable(BlackboxTests_FastRTPS ${BLACKBOXTESTS_FASTRTPS_SOURCE})
target_compile_definitions(BlackboxTests_FastRTPS PRIVATE
BOOST_ASIO_STANDALONE
ASIO_STANDALONE
$<$<NOT:$<BOOL:${IS_THIRDPARTY_BOOST_SUPPORTED}>>:FASTDDS_SHM_TRANSPORT_DISABLED> # Do not compile SHM Transport
)
target_include_directories(BlackboxTests_FastRTPS PRIVATE
api/fastrtps_deprecated
${GTEST_INCLUDE_DIRS})
target_link_libraries(BlackboxTests_FastRTPS fastrtps fastcdr foonathan_memory ${GTEST_LIBRARIES})
${Asio_INCLUDE_DIR}
api/fastrtps_deprecated)
target_link_libraries(BlackboxTests_FastRTPS fastrtps fastcdr foonathan_memory GTest::gtest)
add_blackbox_gtest(BlackboxTests_FastRTPS SOURCES ${BLACKBOXTESTS_TEST_SOURCE}
ENVIRONMENTS "CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs"
"TOPIC_RANDOM_NUMBER=${TOPIC_RANDOM_NUMBER}"
Expand All @@ -272,12 +276,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND)
)
add_executable(BlackboxTests_DDS_PIM ${BLACKBOXTESTS_FASTDDS_PIM_SOURCE})
target_compile_definitions(BlackboxTests_DDS_PIM PRIVATE
BOOST_ASIO_STANDALONE
ASIO_STANDALONE
$<$<NOT:$<BOOL:${IS_THIRDPARTY_BOOST_SUPPORTED}>>:FASTDDS_SHM_TRANSPORT_DISABLED> # Do not compile SHM Transport
)
target_include_directories(BlackboxTests_DDS_PIM PRIVATE
api/dds-pim
${GTEST_INCLUDE_DIRS})
target_link_libraries(BlackboxTests_DDS_PIM fastrtps fastcdr foonathan_memory ${GTEST_LIBRARIES})
${Asio_INCLUDE_DIR}
api/dds-pim)
target_link_libraries(BlackboxTests_DDS_PIM fastrtps fastcdr foonathan_memory GTest::gtest)
add_blackbox_gtest(BlackboxTests_DDS_PIM SOURCES ${DDS_BLACKBOXTESTS_SOURCE}
ENVIRONMENTS "CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs"
"TOPIC_RANDOM_NUMBER=${TOPIC_RANDOM_NUMBER}"
Expand Down
Loading

0 comments on commit a3acef8

Please sign in to comment.