From fba6e46a3803c669eaff95918d4bd16b08dfc469 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 19 Jul 2022 16:47:15 +0200 Subject: [PATCH] Refs #15163: backport #2054 to 2.1.x Signed-off-by: JLBuenoLopez-eProsima --- cmake/common/gtest.cmake | 60 -------- cmake/modules/FindGMock.cmake | 130 ------------------ colcon.pkg | 4 +- .../C++/DDS/DeadlineQoSExample/CMakeLists.txt | 13 +- .../C++/DeadlineQoSExample/CMakeLists.txt | 12 +- test/CMakeLists.txt | 9 +- test/blackbox/CMakeLists.txt | 34 ++--- test/communication/CMakeLists.txt | 31 +++-- test/performance/CMakeLists.txt | 7 - test/performance/latency/CMakeLists.txt | 7 + test/performance/throughput/CMakeLists.txt | 6 +- test/performance/video/CMakeLists.txt | 6 + test/profiling/CMakeLists.txt | 15 +- test/realtime/CMakeLists.txt | 5 +- .../mutex_testing_tool/CMakeLists.txt | 7 +- test/unittest/CMakeLists.txt | 5 - test/unittest/dds/participant/CMakeLists.txt | 11 +- test/unittest/dds/publisher/CMakeLists.txt | 16 +-- test/unittest/dds/status/CMakeLists.txt | 11 +- test/unittest/dds/subscriber/CMakeLists.txt | 16 +-- test/unittest/dds/topic/CMakeLists.txt | 13 +- test/unittest/dynamic_types/CMakeLists.txt | 34 +++-- test/unittest/logging/CMakeLists.txt | 13 +- test/unittest/rtps/builtin/CMakeLists.txt | 11 +- test/unittest/rtps/common/CMakeLists.txt | 20 ++- test/unittest/rtps/discovery/CMakeLists.txt | 11 +- test/unittest/rtps/flowcontrol/CMakeLists.txt | 15 +- test/unittest/rtps/history/CMakeLists.txt | 26 ++-- test/unittest/rtps/network/CMakeLists.txt | 18 +-- test/unittest/rtps/persistence/CMakeLists.txt | 9 +- test/unittest/rtps/reader/CMakeLists.txt | 11 +- .../rtps/resources/timedevent/CMakeLists.txt | 16 +-- test/unittest/rtps/security/CMakeLists.txt | 18 +-- test/unittest/rtps/writer/CMakeLists.txt | 97 +++++++------ .../security/accesscontrol/CMakeLists.txt | 17 ++- .../security/authentication/CMakeLists.txt | 16 +-- .../security/cryptography/CMakeLists.txt | 8 +- test/unittest/security/logging/CMakeLists.txt | 8 +- test/unittest/transport/CMakeLists.txt | 60 ++++---- test/unittest/utils/CMakeLists.txt | 21 ++- test/unittest/xmlparser/CMakeLists.txt | 12 +- test/unittest/xtypes/CMakeLists.txt | 16 +-- test/xtypes/CMakeLists.txt | 24 ++-- 43 files changed, 316 insertions(+), 583 deletions(-) delete mode 100644 cmake/modules/FindGMock.cmake diff --git a/cmake/common/gtest.cmake b/cmake/common/gtest.cmake index d25857c2857..0b6d880ebd5 100644 --- a/cmake/common/gtest.cmake +++ b/cmake/common/gtest.cmake @@ -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") diff --git a/cmake/modules/FindGMock.cmake b/cmake/modules/FindGMock.cmake deleted file mode 100644 index 2ad9221290b..00000000000 --- a/cmake/modules/FindGMock.cmake +++ /dev/null @@ -1,130 +0,0 @@ -# Locate the Google C++ Mocking Framework. -# (This file is almost an identical copy of the original FindGTest.cmake file, -# feel free to use it as it is or modify it for your own needs.) -# -# -# Defines the following variables: -# -# GMOCK_FOUND - Found the Google Testing framework -# GMOCK_INCLUDE_DIRS - Include directories -# -# Also defines the library variables below as normal -# variables. These contain debug/optimized keywords when -# a debugging library is found. -# -# GMOCK_BOTH_LIBRARIES - Both libgmock & libgmock-main -# GMOCK_LIBRARIES - libgmock -# GMOCK_MAIN_LIBRARIES - libgmock-main -# -# Accepts the following variables as input: -# -# GMOCK_ROOT - (as a CMake or environment variable) -# The root directory of the gmock install prefix -# -# GMOCK_MSVC_SEARCH - If compiling with MSVC, this variable can be set to -# "MD" or "MT" to enable searching a gmock build tree -# (defaults: "MD") -# -#----------------------- -# Example Usage: -# -# find_package(GMock REQUIRED) -# include_directories(${GMOCK_INCLUDE_DIRS}) -# -# add_executable(foo foo.cc) -# target_link_libraries(foo ${GMOCK_BOTH_LIBRARIES}) -# -#============================================================================= -# This file is released under the MIT licence: -# -# Copyright (c) 2011 Matej Svec -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -#============================================================================= - - -function(_gmock_append_debugs _endvar _library) - if(${_library} AND ${_library}_DEBUG) - set(_output optimized ${${_library}} debug ${${_library}_DEBUG}) - else() - set(_output ${${_library}}) - endif() - set(${_endvar} ${_output} PARENT_SCOPE) -endfunction() - -function(_gmock_find_library _name) - find_library(${_name} - NAMES ${ARGN} - HINTS - $ENV{GMOCK_ROOT} - ${GMOCK_ROOT} - PATH_SUFFIXES ${_gmock_libpath_suffixes} - ) - mark_as_advanced(${_name}) -endfunction() - - -if(NOT DEFINED GMOCK_MSVC_SEARCH) - set(GMOCK_MSVC_SEARCH MD) -endif() - -set(_gmock_libpath_suffixes lib) -if(MSVC) - if(GMOCK_MSVC_SEARCH STREQUAL "MD") - list(APPEND _gmock_libpath_suffixes - msvc/gmock-md/Debug - msvc/gmock-md/Release) - elseif(GMOCK_MSVC_SEARCH STREQUAL "MT") - list(APPEND _gmock_libpath_suffixes - msvc/gmock/Debug - msvc/gmock/Release) - endif() -endif() - -find_path(GMOCK_INCLUDE_DIR gmock/gmock.h - HINTS - $ENV{GMOCK_ROOT}/include - ${GMOCK_ROOT}/include -) -mark_as_advanced(GMOCK_INCLUDE_DIR) - -if(MSVC AND GMOCK_MSVC_SEARCH STREQUAL "MD") - # The provided /MD project files for Google Mock add -md suffixes to the - # library names. - _gmock_find_library(GMOCK_LIBRARY gmock-md gmock) - _gmock_find_library(GMOCK_LIBRARY_DEBUG gmock-mdd gmockd) - _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main-md gmock_main) - _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_main-mdd gmock_maind) -else() - _gmock_find_library(GMOCK_LIBRARY gmock) - _gmock_find_library(GMOCK_LIBRARY_DEBUG gmockd) - _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main) - _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_maind) -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMock DEFAULT_MSG GMOCK_LIBRARY GMOCK_INCLUDE_DIR GMOCK_MAIN_LIBRARY) - -if(GMOCK_FOUND) - set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIR}) - _gmock_append_debugs(GMOCK_LIBRARIES GMOCK_LIBRARY) - _gmock_append_debugs(GMOCK_MAIN_LIBRARIES GMOCK_MAIN_LIBRARY) - set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES}) -endif() - diff --git a/colcon.pkg b/colcon.pkg index 6814b3477a2..d71654b9523 100644 --- a/colcon.pkg +++ b/colcon.pkg @@ -1,5 +1,5 @@ { "name": "fastrtps", "type": "cmake", - "dependencies" : ["fastcdr", "FOONATHAN_MEMORY", "foonathan_memory_vendor"] -} \ No newline at end of file + "dependencies" : ["fastcdr", "FOONATHAN_MEMORY", "foonathan_memory_vendor", "googletest-distribution"] +} diff --git a/examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt b/examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt index 52a5ec20e57..01f6d2ad4e5 100644 --- a/examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt +++ b/examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt @@ -60,15 +60,12 @@ endif() message(STATUS "Configuring DDSDeadlineQoS example...") file(GLOB DDS_DEADLINEQOS_EXAMPLE_SOURCES "*.cxx") - -add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE -) - -include_directories(${ASIO_INCLUDE_DIR}) - add_executable(DDSDeadlineQoSExample ${DDS_DEADLINEQOS_EXAMPLE_SOURCES}) +target_compile_definitions(DDSDeadlineQoSExample PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) +target_include_directories(DDSDeadlineQoSExample PRIVATE ${Asio_INCLUDE_DIR}) target_link_libraries(DDSDeadlineQoSExample fastrtps fastcdr foonathan_memory) if(UNIX) target_link_libraries(DDSDeadlineQoSExample pthread) diff --git a/examples/C++/DeadlineQoSExample/CMakeLists.txt b/examples/C++/DeadlineQoSExample/CMakeLists.txt index 9d7ec20c4b9..7713d968cdf 100644 --- a/examples/C++/DeadlineQoSExample/CMakeLists.txt +++ b/examples/C++/DeadlineQoSExample/CMakeLists.txt @@ -61,14 +61,12 @@ endif() message(STATUS "Configuring DeadlineQoS example...") file(GLOB DEADLINEQOS_EXAMPLE_SOURCES "*.cxx") -add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE -) - -include_directories(${ASIO_INCLUDE_DIR}) - add_executable(DeadlineQoSExample ${DEADLINEQOS_EXAMPLE_SOURCES}) +target_compile_definitions(DeadlineQoSExample PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) +target_include_directories(DeadlineQoSExample PRIVATE ${Asio_INCLUDE_DIR}) target_link_libraries(DeadlineQoSExample fastrtps fastcdr foonathan_memory) if(UNIX) target_link_libraries(DeadlineQoSExample pthread) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ccf77809196..44328183165 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) @@ -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) diff --git a/test/blackbox/CMakeLists.txt b/test/blackbox/CMakeLists.txt index a29b6c665ea..8cdd9b20188 100644 --- a/test/blackbox/CMakeLists.txt +++ b/test/blackbox/CMakeLists.txt @@ -141,10 +141,7 @@ 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 @@ -152,13 +149,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) ) endif() - add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE - ) - - include_directories(${ASIO_INCLUDE_DIR}) - ############################################################################### # Unit tests ############################################################################### @@ -183,11 +173,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 $<$>: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") @@ -249,12 +241,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 $<$>: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}" @@ -272,12 +266,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 $<$>: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}" diff --git a/test/communication/CMakeLists.txt b/test/communication/CMakeLists.txt index 58e5453df6f..97e73c7ae37 100644 --- a/test/communication/CMakeLists.txt +++ b/test/communication/CMakeLists.txt @@ -15,13 +15,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) find_package(PythonInterp 3) - add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE - ) - - include_directories(${ASIO_INCLUDE_DIR}) - ############################################################################### # Binaries ############################################################################### @@ -34,7 +27,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) PublisherMain.cpp ) add_executable(SimpleCommunicationPublisher ${PUBLISHER_SOURCE}) - target_include_directories(SimpleCommunicationPublisher PRIVATE ${PROJECT_SOURCE_DIR}/test/blackbox) + target_compile_definitions(SimpleCommunicationPublisher PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) + target_include_directories(SimpleCommunicationPublisher PRIVATE + ${Asio_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/test/blackbox) target_link_libraries(SimpleCommunicationPublisher fastrtps fastcdr foonathan_memory ${CMAKE_DL_LIBS}) set(SUBSCRIBER_SOURCE ${COMMON_SOURCE} @@ -42,7 +41,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) SubscriberMain.cpp ) add_executable(SimpleCommunicationSubscriber ${SUBSCRIBER_SOURCE}) - target_include_directories(SimpleCommunicationSubscriber PRIVATE ${PROJECT_SOURCE_DIR}/test/blackbox) + target_compile_definitions(SimpleCommunicationSubscriber PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) + target_include_directories(SimpleCommunicationSubscriber PRIVATE + ${Asio_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/test/blackbox) target_link_libraries(SimpleCommunicationSubscriber fastrtps fastcdr foonathan_memory ${CMAKE_DL_LIBS}) set(PUBSUB_SOURCE ${COMMON_SOURCE} @@ -52,7 +57,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) ) add_executable(SimpleCommunicationPubSub ${PUBSUB_SOURCE}) - target_include_directories(SimpleCommunicationPubSub PRIVATE ${PROJECT_SOURCE_DIR}/test/blackbox) + target_compile_definitions(SimpleCommunicationPubSub PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) + target_include_directories(SimpleCommunicationPubSub PRIVATE + ${Asio_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/test/blackbox) target_link_libraries(SimpleCommunicationPubSub fastrtps fastcdr foonathan_memory ${CMAKE_DL_LIBS}) ############################################################################### diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt index 4ff81e71f6a..d5c977fb234 100644 --- a/test/performance/CMakeLists.txt +++ b/test/performance/CMakeLists.txt @@ -23,13 +23,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) endif() endif() - add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE - ) - - include_directories(${ASIO_INCLUDE_DIR}) - option(VIDEO_TESTS "Activate the building and execution of performance tests" OFF) add_subdirectory(latency) add_subdirectory(throughput) diff --git a/test/performance/latency/CMakeLists.txt b/test/performance/latency/CMakeLists.txt index 0c5a7ee8e6a..492d7eada61 100644 --- a/test/performance/latency/CMakeLists.txt +++ b/test/performance/latency/CMakeLists.txt @@ -23,6 +23,13 @@ set( ) add_executable(LatencyTest ${LATENCYTEST_SOURCE}) +target_compile_definitions(LatencyTest PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) + +target_include_directories(LatencyTest PRIVATE ${Asio_INCLUDE_DIR}) + target_link_libraries( LatencyTest fastrtps diff --git a/test/performance/throughput/CMakeLists.txt b/test/performance/throughput/CMakeLists.txt index 2a536de838c..718bf646bf0 100644 --- a/test/performance/throughput/CMakeLists.txt +++ b/test/performance/throughput/CMakeLists.txt @@ -23,7 +23,11 @@ set( ) add_executable(ThroughputTest ${THROUGHPUTTEST_SOURCE}) -target_include_directories(ThroughputTest PRIVATE) +target_compile_definitions(ThroughputTest PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) +target_include_directories(ThroughputTest PRIVATE ${Asio_INCLUDE_DIR}) target_link_libraries( ThroughputTest fastrtps diff --git a/test/performance/video/CMakeLists.txt b/test/performance/video/CMakeLists.txt index 8f963cd4a9c..522a5cc1605 100644 --- a/test/performance/video/CMakeLists.txt +++ b/test/performance/video/CMakeLists.txt @@ -77,18 +77,24 @@ if(GST_FOUND) main_VideoTest.cpp ) add_executable(VideoTest ${VIDEOTEST_SOURCE}) + target_compile_definitions(VideoTest PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_compile_options(VideoTest PUBLIC ${GST_CFLAGS}) if(NOT WIN32) target_include_directories( VideoTest PUBLIC + ${Asio_INCLUDE_DIR} ${GST_INCLUDE_DIRS} ) else() target_include_directories( VideoTest PUBLIC + ${Asio_INCLUDE_DIR} $ENV{GSTREAMER_1_0_ROOT_X86_64}/include $ENV{GSTREAMER_1_0_ROOT_X86_64}/include/glib-2.0 $ENV{GSTREAMER_1_0_ROOT_X86_64}/include/gstreamer-1.0 diff --git a/test/profiling/CMakeLists.txt b/test/profiling/CMakeLists.txt index b035351aea5..ca987aa81af 100644 --- a/test/profiling/CMakeLists.txt +++ b/test/profiling/CMakeLists.txt @@ -17,18 +17,18 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$,$>:_WIN32_WINNT=0x0603> $<$,$>>:_WIN32_WINNT=0x0601> ) + else() + target_compile_definitions(${PROJECT_NAME} PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) endif() - add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE - ) - - include_directories(${ASIO_INCLUDE_DIR}) - ############################################################################### # Binaries ############################################################################### @@ -38,6 +38,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) main_MemoryTest.cpp ) add_executable(MemoryTest ${MEMORYTEST_SOURCE}) + target_include_directories(MemoryTest PRIVATE ${Asio_INCLUDE_DIR}) target_link_libraries(MemoryTest fastrtps foonathan_memory ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) configure_file("cycles_tests.py" "cycles_tests.py") diff --git a/test/realtime/CMakeLists.txt b/test/realtime/CMakeLists.txt index 44a4017e642..1304b4ebbf0 100644 --- a/test/realtime/CMakeLists.txt +++ b/test/realtime/CMakeLists.txt @@ -1,12 +1,11 @@ add_subdirectory(mutex_testing_tool) -if(GTEST_FOUND) +if(GTest_FOUND) set(USER_THREAD_NONBLOCKED_TEST UserThreadNonBlockedTest.cpp) add_executable(user_thread_nonblocked_test ${USER_THREAD_NONBLOCKED_TEST}) - target_include_directories(user_thread_nonblocked_test PRIVATE ${GTEST_INCLUDE_DIRS}) - target_link_libraries(user_thread_nonblocked_test mutex_testing_tool fastrtps fastcdr ${GTEST_LIBRARIES}) + target_link_libraries(user_thread_nonblocked_test mutex_testing_tool fastrtps fastcdr GTest::gtest) STRING(REPLACE " " "\\ " MUTEX_PRELOAD_LIBRARY_FILE "$") add_gtest(NAME UserThreadNonBlockedTest COMMAND user_thread_nonblocked_test SOURCES ${USER_THREAD_NONBLOCKED_TEST} diff --git a/test/realtime/mutex_testing_tool/CMakeLists.txt b/test/realtime/mutex_testing_tool/CMakeLists.txt index fb5cc2d0a2e..9ca1da234ac 100644 --- a/test/realtime/mutex_testing_tool/CMakeLists.txt +++ b/test/realtime/mutex_testing_tool/CMakeLists.txt @@ -15,15 +15,14 @@ include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) check_gtest() -if(GTEST_FOUND) +if(GTest_FOUND) add_library(mutex_testing_tool SHARED TMutex.cpp) add_library(mutex_testing_tool_preload SHARED Mutex.cpp) target_link_libraries(mutex_testing_tool_preload PRIVATE mutex_testing_tool ${CMAKE_DL_LIBS}) add_executable(TMutexTests TMutexTests.cpp) - target_include_directories(TMutexTests PRIVATE ${GTEST_INCLUDE_DIRS}) - target_link_libraries(TMutexTests mutex_testing_tool ${GTEST_LIBRARIES}) + target_link_libraries(TMutexTests mutex_testing_tool GTest::gtest) STRING(REPLACE " " "\\ " MUTEX_PRELOAD_LIBRARY_FILE "$") add_gtest(TMutexTests SOURCES TMutexTests.cpp ENVIRONMENTS @@ -31,4 +30,4 @@ if(GTEST_FOUND) "LD_PRELOAD=$" LABELS "NoMemoryCheck" ) -endif(GTEST_FOUND) \ No newline at end of file +endif(GTest_FOUND) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index f9744d052e5..fc25cd6c3a3 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -12,11 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE -) - add_subdirectory(rtps/common) add_subdirectory(rtps/builtin) add_subdirectory(rtps/reader) diff --git a/test/unittest/dds/participant/CMakeLists.txt b/test/unittest/dds/participant/CMakeLists.txt index 92eec6e6eeb..b849c14408f 100644 --- a/test/unittest/dds/participant/CMakeLists.txt +++ b/test/unittest/dds/participant/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../profiles/test_xml_profiles.xml @@ -34,13 +30,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(ParticipantTests ${PARTICIPANTTESTS_SOURCE}) target_compile_definitions(ParticipantTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(ParticipantTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(ParticipantTests fastrtps fastcdr foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(ParticipantTests SOURCES ${PARTICIPANTTESTS_SOURCE}) endif() endif() diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 6e26de8f9d4..3fe864e700f 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../profiles/test_xml_profiles.xml @@ -37,25 +33,23 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(PublisherTests ${PUBLISHERTESTS_SOURCE}) target_compile_definitions(PublisherTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(PublisherTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(PublisherTests fastrtps fastcdr foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(PublisherTests SOURCES ${PUBLISHERTESTS_SOURCE}) add_executable(DataWriterTests ${DATAWRITERTESTS_SOURCE}) target_compile_definitions(DataWriterTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(DataWriterTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(DataWriterTests fastrtps fastcdr foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(DataWriterTests SOURCES ${DATAWRITERTESTS_SOURCE}) endif() endif() diff --git a/test/unittest/dds/status/CMakeLists.txt b/test/unittest/dds/status/CMakeLists.txt index 15df61878db..7fd20631ead 100644 --- a/test/unittest/dds/status/CMakeLists.txt +++ b/test/unittest/dds/status/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) set(LISTENERTESTS_SOURCE ListenerTests.cpp @@ -104,7 +100,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(ListenerTests ${LISTENERTESTS_SOURCE}) target_compile_definitions(ListenerTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(ListenerTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSDomain @@ -136,8 +131,8 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) target_link_libraries(ListenerTests fastcdr foonathan_memory ${TINYXML2_LIBRARY} - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(ListenerTests SOURCES ${LISTENERTESTS_SOURCE}) endif() diff --git a/test/unittest/dds/subscriber/CMakeLists.txt b/test/unittest/dds/subscriber/CMakeLists.txt index d92d61db222..e21b93aa888 100644 --- a/test/unittest/dds/subscriber/CMakeLists.txt +++ b/test/unittest/dds/subscriber/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../profiles/test_xml_profiles.xml @@ -34,25 +30,23 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(SubscriberTests ${SUBSCRIBERTESTS_SOURCE}) target_compile_definitions(SubscriberTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(SubscriberTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(SubscriberTests fastrtps fastcdr foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(SubscriberTests SOURCES ${SUBSCRIBERTESTS_SOURCE}) add_executable(DataReaderTests ${DATAREADERTESTS_SOURCE}) target_compile_definitions(DataReaderTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(DataReaderTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(DataReaderTests fastrtps fastcdr foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(DataReaderTests SOURCES ${DATAREADERTESTS_SOURCE}) endif() endif() diff --git a/test/unittest/dds/topic/CMakeLists.txt b/test/unittest/dds/topic/CMakeLists.txt index 8c6d58911a5..2faf69b57e1 100644 --- a/test/unittest/dds/topic/CMakeLists.txt +++ b/test/unittest/dds/topic/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../profiles/test_xml_profiles.xml @@ -25,7 +21,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) COPYONLY) set(TOPICTESTS_SOURCE TopicTests.cpp) - + if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() @@ -33,13 +29,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(TopicTests ${TOPICTESTS_SOURCE}) target_compile_definitions(TopicTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(TopicTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(TopicTests fastrtps fastcdr foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(TopicTests SOURCES ${TOPICTESTS_SOURCE}) endif() diff --git a/test/unittest/dynamic_types/CMakeLists.txt b/test/unittest/dynamic_types/CMakeLists.txt index 96cc59f94b1..19cbdfbbacd 100644 --- a/test/unittest/dynamic_types/CMakeLists.txt +++ b/test/unittest/dynamic_types/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions( -D_WIN32_WINNT=0x0601 @@ -24,8 +21,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) endif() - include_directories(${ASIO_INCLUDE_DIR}) - set(DYNAMIC_TYPES_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicData.cpp @@ -103,9 +98,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) include_directories(mock/) add_executable(DynamicTypesTests ${DYNAMIC_TYPES_TEST_SOURCE}) - target_compile_definitions(DynamicTypesTests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(DynamicTypesTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(DynamicTypesTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPTransportDescriptor ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPv4TransportDescriptor ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPv6TransportDescriptor @@ -116,7 +114,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${TINYXML2_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) - target_link_libraries(DynamicTypesTests ${GTEST_LIBRARIES} + target_link_libraries(DynamicTypesTests GTest::gtest $<$:iphlpapi$Shlwapi> $<$:ws2_32> ${TINYXML2_LIBRARY} @@ -126,11 +124,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(DynamicComplexTypesTests ${DYNAMIC_COMPLEX_TYPES_TEST_SOURCE}) - target_compile_definitions(DynamicComplexTypesTests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(DynamicComplexTypesTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(DynamicComplexTypesTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(DynamicComplexTypesTests ${GTEST_LIBRARIES} + target_link_libraries(DynamicComplexTypesTests GTest::gtest $<$:iphlpapi$Shlwapi> $<$:ws2_32> ${TINYXML2_LIBRARY} @@ -140,11 +141,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(DynamicTypes_4_2_Tests ${DYNAMIC_TYPES_4_2_TEST_SOURCE}) - target_compile_definitions(DynamicTypes_4_2_Tests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(DynamicTypes_4_2_Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(DynamicTypes_4_2_Tests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(DynamicTypes_4_2_Tests ${GTEST_LIBRARIES} + target_link_libraries(DynamicTypes_4_2_Tests GTest::gtest $<$:iphlpapi$Shlwapi> $<$:ws2_32> ${TINYXML2_LIBRARY} diff --git a/test/unittest/logging/CMakeLists.txt b/test/unittest/logging/CMakeLists.txt index 3584e951341..5afa27444e9 100644 --- a/test/unittest/logging/CMakeLists.txt +++ b/test/unittest/logging/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() @@ -38,9 +35,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(LogTests ${LOGTESTS_SOURCE}) target_compile_definitions(LogTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(LogTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ) add_gtest(LogTests SOURCES ${LOGTESTS_TEST_SOURCE}) @@ -63,9 +60,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(LogFileTests ${LOGFILETESTS_SOURCE}) target_compile_definitions(LogFileTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(LogFileTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogFileTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogFileTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogFileTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ${TINYXML2_LIBRARY} fastcdr diff --git a/test/unittest/rtps/builtin/CMakeLists.txt b/test/unittest/rtps/builtin/CMakeLists.txt index 2057bf1f66a..e67c24eddd1 100644 --- a/test/unittest/rtps/builtin/CMakeLists.txt +++ b/test/unittest/rtps/builtin/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) set(BUILTIN_DATA_SERIALIZATION_TESTS_SOURCE BuiltinDataSerializationTests.cpp @@ -73,14 +69,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) target_include_directories(BuiltinDataSerializationTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(BuiltinDataSerializationTests foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) if(MSVC OR MSVC_IDE) target_link_libraries(BuiltinDataSerializationTests ${PRIVACY} fastcdr iphlpapi Shlwapi ws2_32) else() diff --git a/test/unittest/rtps/common/CMakeLists.txt b/test/unittest/rtps/common/CMakeLists.txt index 4dc5bc51d23..5f63e176e34 100644 --- a/test/unittest/rtps/common/CMakeLists.txt +++ b/test/unittest/rtps/common/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) set(CACHECHANGETESTS_SOURCE CacheChangeTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp) set(GUID_UTILS_TESTS_SOURCE GuidUtilsTests.cpp @@ -32,18 +29,17 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(CacheChangeTests ${CACHECHANGETESTS_SOURCE}) target_compile_definitions(CacheChangeTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(CacheChangeTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(CacheChangeTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(CacheChangeTests ${GTEST_LIBRARIES}) + target_link_libraries(CacheChangeTests GTest::gtest) add_gtest(CacheChangeTests SOURCES ${CACHECHANGETESTS_SOURCE}) add_executable(GuidUtilsTests ${GUID_UTILS_TESTS_SOURCE}) target_compile_definitions(GuidUtilsTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(GuidUtilsTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(GuidUtilsTests ${GTEST_LIBRARIES}) + target_link_libraries(GuidUtilsTests GTest::gtest) if(MSVC OR MSVC_IDE) target_link_libraries(GuidUtilsTests ws2_32) endif() @@ -51,16 +47,16 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(SequenceNumberTests ${SEQUENCENUMBERTESTS_SOURCE}) target_compile_definitions(SequenceNumberTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(SequenceNumberTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(SequenceNumberTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(SequenceNumberTests ${GTEST_LIBRARIES}) + target_link_libraries(SequenceNumberTests GTest::gtest) add_gtest(SequenceNumberTests SOURCES ${SEQUENCENUMBERTESTS_SOURCE}) add_executable(PortParametersTests ${PORTPARAMETERSTESTS_SOURCE}) target_compile_definitions(PortParametersTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(PortParametersTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(PortParametersTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(PortParametersTests ${GTEST_LIBRARIES}) + target_link_libraries(PortParametersTests GTest::gtest) add_gtest(PortParametersTests SOURCES ${PORTPARAMETERSTESTS_SOURCE} LABELS "NoMemoryCheck") endif() endif() diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index c48fb67832a..afc1216e10f 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) set(EDPTESTS_SOURCE EdpTests.cpp @@ -64,7 +60,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(EdpTests ${EDPTESTS_SOURCE}) target_compile_definitions(EdpTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(EdpTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/PDP ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint @@ -83,8 +78,8 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(EdpTests foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) if(MSVC OR MSVC_IDE) target_link_libraries(EdpTests ${PRIVACY} fastcdr iphlpapi Shlwapi ws2_32) else() diff --git a/test/unittest/rtps/flowcontrol/CMakeLists.txt b/test/unittest/rtps/flowcontrol/CMakeLists.txt index 39d7628bc9f..8333921ebcf 100644 --- a/test/unittest/rtps/flowcontrol/CMakeLists.txt +++ b/test/unittest/rtps/flowcontrol/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() @@ -31,8 +28,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp) add_executable(ThroughputControllerTests ${THROUGHPUTCONTROLLERTESTS_SOURCE}) - target_compile_definitions(ThroughputControllerTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(ThroughputControllerTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_compile_definitions(ThroughputControllerTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) + target_include_directories(ThroughputControllerTests PRIVATE + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/AsyncWriterThread ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl @@ -41,7 +42,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(ThroughputControllerTests ${GTEST_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES}) + target_link_libraries(ThroughputControllerTests GTest::gmock) if(MSVC OR MSVC_IDE) target_link_libraries(ThroughputControllerTests ${PRIVACY} iphlpapi Shlwapi diff --git a/test/unittest/rtps/history/CMakeLists.txt b/test/unittest/rtps/history/CMakeLists.txt index 90784fd533b..8f65afc6e0b 100644 --- a/test/unittest/rtps/history/CMakeLists.txt +++ b/test/unittest/rtps/history/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) set(READERHISTORYTESTS_SOURCE ReaderHistoryTests.cpp @@ -63,49 +59,45 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(ReaderHistoryTests ${READERHISTORYTESTS_SOURCE}) target_compile_definitions(ReaderHistoryTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(ReaderHistoryTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulReader ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) target_link_libraries(ReaderHistoryTests - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(ReaderHistoryTests SOURCES ${READERHISTORYTESTS_SOURCE}) add_executable(BasicPoolsTests ${BASICPOOLSTESTS_SOURCE}) target_compile_definitions(BasicPoolsTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(BasicPoolsTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) target_link_libraries(BasicPoolsTests - ${GTEST_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gtest + ${CMAKE_DL_LIBS}) add_gtest(BasicPoolsTests SOURCES ${BASICPOOLSTESTS_SOURCE}) add_executable(CacheChangePoolTests ${CACHECHANGEPOOLTESTS_SOURCE}) target_compile_definitions(CacheChangePoolTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(CacheChangePoolTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) target_link_libraries(CacheChangePoolTests - ${GTEST_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gtest + ${CMAKE_DL_LIBS}) add_gtest(CacheChangePoolTests SOURCES ${CACHECHANGEPOOLTESTS_SOURCE}) add_executable(TopicPayloadPoolTests ${TOPICPAYLOADPOOLTESTS_SOURCE}) target_compile_definitions(TopicPayloadPoolTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(TopicPayloadPoolTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/TopicPayloadPoolProxy ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) target_link_libraries(TopicPayloadPoolTests - ${GTEST_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gtest + ${CMAKE_DL_LIBS}) add_gtest(TopicPayloadPoolTests SOURCES ${TOPICPAYLOADPOOLTESTS_SOURCE}) endif() diff --git a/test/unittest/rtps/network/CMakeLists.txt b/test/unittest/rtps/network/CMakeLists.txt index 03e35d3d439..c8bd982734a 100644 --- a/test/unittest/rtps/network/CMakeLists.txt +++ b/test/unittest/rtps/network/CMakeLists.txt @@ -13,16 +13,9 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) - include_directories(${ASIO_INCLUDE_DIR}) - + if(GTest_FOUND) find_package(Threads REQUIRED) - include_directories(${ASIO_INCLUDE_DIR}) - set(NETWORKFACTORYTESTS_SOURCE NetworkFactoryTests.cpp mock/MockTransport.cpp @@ -77,9 +70,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) include_directories(mock/) add_executable(NetworkFactoryTests ${NETWORKFACTORYTESTS_SOURCE}) - target_compile_definitions(NetworkFactoryTests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(NetworkFactoryTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(NetworkFactoryTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/dds/QosPolicies ${PROJECT_SOURCE_DIR}/test/mock/rtps/MessageReceiver @@ -88,7 +84,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(NetworkFactoryTests fastcdr foonathan_memory - ${GTEST_LIBRARIES} ${MOCKS} + GTest::gtest ${MOCKS} $<$:OpenSSL::SSL$OpenSSL::Crypto> ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) diff --git a/test/unittest/rtps/persistence/CMakeLists.txt b/test/unittest/rtps/persistence/CMakeLists.txt index f779f2892ff..3fcc996e0af 100644 --- a/test/unittest/rtps/persistence/CMakeLists.txt +++ b/test/unittest/rtps/persistence/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND AND SQLITE3_SUPPORT) + if(GTest_FOUND AND SQLITE3_SUPPORT) set(PERSISTENCETESTS_SOURCE PersistenceTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp @@ -32,11 +29,11 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(PersistenceTests ${PERSISTENCETESTS_SOURCE}) target_compile_definitions(PersistenceTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(PersistenceTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(PersistenceTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(PersistenceTests foonathan_memory ${GTEST_LIBRARIES} ${CMAKE_DL_LIBS}) + target_link_libraries(PersistenceTests foonathan_memory GTest::gtest ${CMAKE_DL_LIBS}) if(MSVC OR MSVC_IDE) target_link_libraries(PersistenceTests ${PRIVACY} iphlpapi Shlwapi diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index 77b3e3a8251..904ca204f8f 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) set(WRITERPROXYTESTS_SOURCE WriterProxyTests.cpp @@ -36,7 +32,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(WriterProxyTests ${WRITERPROXYTESTS_SOURCE}) target_compile_definitions(WriterProxyTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(WriterProxyTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader @@ -52,8 +47,8 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(WriterProxyTests foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(WriterProxyTests SOURCES ${WRITERPROXYTESTS_SOURCE}) endif() endif() diff --git a/test/unittest/rtps/resources/timedevent/CMakeLists.txt b/test/unittest/rtps/resources/timedevent/CMakeLists.txt index ee649ace331..3b4f52873ec 100644 --- a/test/unittest/rtps/resources/timedevent/CMakeLists.txt +++ b/test/unittest/rtps/resources/timedevent/CMakeLists.txt @@ -13,14 +13,9 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) find_package(Threads REQUIRED) - include_directories(${ASIO_INCLUDE_DIR}) - set(TIMEDEVENTTESTS_SOURCE mock/MockEvent.cpp TimedEventTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp @@ -35,14 +30,17 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) endif() add_executable(TimedEventTests ${TIMEDEVENTTESTS_SOURCE}) - target_compile_definitions(TimedEventTests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(TimedEventTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(TimedEventTests PRIVATE - ${GTEST_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(TimedEventTests ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + target_link_libraries(TimedEventTests GTest::gtest ${CMAKE_DL_LIBS}) add_gtest(TimedEventTests SOURCES ${TIMEDEVENTTESTS_SOURCE}) endif() endif() diff --git a/test/unittest/rtps/security/CMakeLists.txt b/test/unittest/rtps/security/CMakeLists.txt index bc30f799636..37dd29eedb2 100644 --- a/test/unittest/rtps/security/CMakeLists.txt +++ b/test/unittest/rtps/security/CMakeLists.txt @@ -13,17 +13,11 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() - include_directories(${ASIO_INCLUDE_DIR}) - set(SOURCES_SECURITY_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp @@ -59,9 +53,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/SecurityValidationRemoteTests.cpp PROPERTIES COMPILE_OPTIONS /bigobj) endif() - target_compile_definitions(SecurityAuthentication PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(SecurityAuthentication PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(SecurityAuthentication PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/SecurityPluginFactory ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint @@ -85,8 +82,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(SecurityAuthentication fastcdr - ${GTEST_LIBRARIES} - ${GMOCK_LIBRARIES} + GTest::gmock ${OPENSSL_LIBRARIES} ) add_gtest(SecurityAuthentication diff --git a/test/unittest/rtps/writer/CMakeLists.txt b/test/unittest/rtps/writer/CMakeLists.txt index 6641273ada7..eb694aa4c2a 100644 --- a/test/unittest/rtps/writer/CMakeLists.txt +++ b/test/unittest/rtps/writer/CMakeLists.txt @@ -13,15 +13,9 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) - find_package(Threads REQUIRED) - - # ReaderProxy + if(GTest_FOUND) + # ReaderProxy set(WRITERPROXYTESTS_SOURCE ReaderProxyTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/ReaderProxy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp @@ -36,12 +30,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_definitions(-D_WIN32_WINNT=0x0601) endif() - include_directories(${ASIO_INCLUDE_DIR}) - add_executable(ReaderProxyTests ${WRITERPROXYTESTS_SOURCE}) - target_compile_definitions(ReaderProxyTests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(ReaderProxyTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(ReaderProxyTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory @@ -57,50 +52,52 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(ReaderProxyTests - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} foonathan_memory - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(ReaderProxyTests SOURCES ${WRITERPROXYTESTS_SOURCE}) - # LivelinessManager - - set(LIVELINESSMANAGERTESTS_SOURCE LivelinessManagerTests.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LivelinessManager.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp - ) - add_executable(LivelinessManagerTests ${LIVELINESSMANAGERTESTS_SOURCE}) + # LivelinessManager + set(LIVELINESSMANAGERTESTS_SOURCE LivelinessManagerTests.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LivelinessManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp + ) + add_executable(LivelinessManagerTests ${LIVELINESSMANAGERTESTS_SOURCE} + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_compile_definitions(LivelinessManagerTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(LivelinessManagerTests PRIVATE - ${GTEST_INCLUDE_DIRS} - ${GMOCK_INCLUDE_DIRS} - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_BINARY_DIR}/include - ${PROJECT_SOURCE_DIR}/src/cpp - ) - target_link_libraries(LivelinessManagerTests PRIVATE - ${GTEST_LIBRARIES} - ${GMOCK_LIBRARIES}) - add_gtest(LivelinessManagerTests SOURCES ${LIVELINESSMANAGERTESTS_SOURCE}) - - # RTPSWriter + ${Asio_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ${PROJECT_SOURCE_DIR}/src/cpp + ) + target_link_libraries(LivelinessManagerTests PRIVATE + GTest::gmock) + add_gtest(LivelinessManagerTests SOURCES ${LIVELINESSMANAGERTESTS_SOURCE}) - set(RTPSWRITERTESTS_SOURCE RTPSWriterTests.cpp) + # RTPSWriter + set(RTPSWRITERTESTS_SOURCE RTPSWriterTests.cpp) - add_executable(RTPSWriterTests ${RTPSWRITERTESTS_SOURCE}) - target_include_directories(RTPSWriterTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} - ) - target_link_libraries(RTPSWriterTests fastrtps foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) - add_gtest(RTPSWriterTests SOURCES ${RTPSWRITERTESTS_SOURCE}) + add_executable(RTPSWriterTests ${RTPSWRITERTESTS_SOURCE}) + target_compile_definitions(RTPSWriterTests PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) + target_include_directories(RTPSWriterTests PRIVATE + ${Asio_INCLUDE_DIR}) + target_link_libraries(RTPSWriterTests fastrtps foonathan_memory + GTest::gmock + ${CMAKE_DL_LIBS}) + add_gtest(RTPSWriterTests SOURCES ${RTPSWRITERTESTS_SOURCE}) endif() endif() diff --git a/test/unittest/security/accesscontrol/CMakeLists.txt b/test/unittest/security/accesscontrol/CMakeLists.txt index f378b7f9d31..55e2f56dac8 100644 --- a/test/unittest/security/accesscontrol/CMakeLists.txt +++ b/test/unittest/security/accesscontrol/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions( -D_WIN32_WINNT=0x0601 @@ -24,8 +21,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) endif() - include_directories(${ASIO_INCLUDE_DIR}) - set(COMMON_SOURCES_ACCESS_CONTROL_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp @@ -70,10 +65,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${CMAKE_CURRENT_SOURCE_DIR}/AccessControlTests.cpp) - target_compile_definitions(AccessControlTests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(AccessControlTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(AccessControlTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory/ ${PROJECT_SOURCE_DIR}/test/mock/rtps/PDPSimple ${PROJECT_SOURCE_DIR}/test/mock/rtps/EDP @@ -87,7 +85,8 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) target_link_libraries(AccessControlTests - ${GTEST_LIBRARIES} ${OPENSSL_LIBRARIES} + GTest::gmock + ${OPENSSL_LIBRARIES} fastcdr foonathan_memory $<$:ws2_32> diff --git a/test/unittest/security/authentication/CMakeLists.txt b/test/unittest/security/authentication/CMakeLists.txt index 385f8f6f738..9254623b89a 100644 --- a/test/unittest/security/authentication/CMakeLists.txt +++ b/test/unittest/security/authentication/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions( -D_WIN32_WINNT=0x0601 @@ -24,8 +21,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) endif() - include_directories(${ASIO_INCLUDE_DIR}) - set(COMMON_SOURCES_AUTH_PLUGIN_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp @@ -55,15 +50,18 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BuiltinPKIDHTests.cpp) - target_compile_definitions(BuiltinPKIDH PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(BuiltinPKIDH PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(BuiltinPKIDH PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory/ ${OPENSSL_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(BuiltinPKIDH ${GTEST_LIBRARIES} ${OPENSSL_LIBRARIES} fastcdr foonathan_memory $<$:ws2_32>) + target_link_libraries(BuiltinPKIDH GTest::gtest ${OPENSSL_LIBRARIES} fastcdr foonathan_memory $<$:ws2_32>) add_gtest(BuiltinPKIDH SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/BuiltinPKIDHTests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/AuthenticationPluginTests.hpp diff --git a/test/unittest/security/cryptography/CMakeLists.txt b/test/unittest/security/cryptography/CMakeLists.txt index da1db33a720..ead170295bd 100644 --- a/test/unittest/security/cryptography/CMakeLists.txt +++ b/test/unittest/security/cryptography/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() @@ -46,12 +43,11 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) target_compile_definitions(BuiltinAESGCMGMAC PRIVATE FASTRTPS_NO_LIB) target_include_directories(BuiltinAESGCMGMAC PRIVATE - ${GTEST_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(BuiltinAESGCMGMAC fastcdr ${GTEST_LIBRARIES} ${OPENSSL_LIBRARIES}) + target_link_libraries(BuiltinAESGCMGMAC fastcdr GTest::gmock ${OPENSSL_LIBRARIES}) add_gtest(BuiltinAESGCMGMAC SOURCES ${COMMON_SOURCES_CRYPTO_PLUGIN_TEST_SOURCE} ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC.cpp ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC_KeyExchange.cpp diff --git a/test/unittest/security/logging/CMakeLists.txt b/test/unittest/security/logging/CMakeLists.txt index 3594076f87c..e9f4b529699 100644 --- a/test/unittest/security/logging/CMakeLists.txt +++ b/test/unittest/security/logging/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() @@ -40,11 +37,10 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) target_compile_definitions(BuiltinLogging PRIVATE FASTRTPS_NO_LIB) target_include_directories(BuiltinLogging PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(BuiltinLogging fastcdr ${GTEST_LIBRARIES} ${OPENSSL_LIBRARIES}) + target_link_libraries(BuiltinLogging fastcdr GTest::gtest ${OPENSSL_LIBRARIES}) add_gtest(BuiltinLogging SOURCES ${COMMON_SOURCES_LOGGING_PLUGIN_TEST_SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/LoggingPluginTests.hpp ${CMAKE_CURRENT_SOURCE_DIR}/BuiltinLogTopicTests.cpp) diff --git a/test/unittest/transport/CMakeLists.txt b/test/unittest/transport/CMakeLists.txt index bd65da3c8ff..f2f478dceb2 100644 --- a/test/unittest/transport/CMakeLists.txt +++ b/test/unittest/transport/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions( -D_WIN32_WINNT=0x0601 @@ -24,8 +21,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) endif() - include_directories(${ASIO_INCLUDE_DIR}) - # Copy certs if(TLS_FOUND) configure_file(${PROJECT_SOURCE_DIR}/test/certs/maincacert.pem @@ -202,15 +197,18 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) include_directories(mock/) add_executable(UDPv4Tests ${UDPV4TESTS_SOURCE}) - target_compile_definitions(UDPv4Tests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(UDPv4Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(UDPv4Tests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/MessageReceiver ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReceiverResource ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(UDPv4Tests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(UDPv4Tests GTest::gtest ${MOCKS}) if(MSVC OR MSVC_IDE) target_link_libraries(UDPv4Tests ${PRIVACY} iphlpapi Shlwapi ) endif() @@ -221,15 +219,18 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) if(NOT DISABLE_UDPV6_TESTS) add_executable(UDPv6Tests ${UDPV6TESTS_SOURCE}) - target_compile_definitions(UDPv6Tests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(UDPv6Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(UDPv6Tests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/MessageReceiver ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReceiverResource ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(UDPv6Tests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(UDPv6Tests GTest::gtest ${MOCKS}) if(MSVC OR MSVC_IDE) target_link_libraries(UDPv6Tests ${PRIVACY} iphlpapi Shlwapi ) endif() @@ -237,9 +238,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) set(TRANSPORT_XFAIL_LIST ${TRANSPORT_XFAIL_LIST} XFAIL_UDP6) add_executable(TCPv6Tests ${TCPV6TESTS_SOURCE}) - target_compile_definitions(TCPv6Tests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(TCPv6Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(TCPv6Tests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/dds/QosPolicies ${PROJECT_SOURCE_DIR}/test/mock/rtps/MessageReceiver @@ -247,7 +251,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(TCPv6Tests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(TCPv6Tests GTest::gtest ${MOCKS} $<$:OpenSSL::SSL$OpenSSL::Crypto>) if(MSVC OR MSVC_IDE) target_link_libraries(TCPv6Tests ${PRIVACY} fastcdr iphlpapi Shlwapi) @@ -259,9 +263,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) endif() add_executable(test_UDPv4Tests ${TEST_UDPV4TESTS_SOURCE}) - target_compile_definitions(test_UDPv4Tests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(test_UDPv4Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(test_UDPv4Tests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/dds/QosPolicies ${PROJECT_SOURCE_DIR}/test/mock/rtps/MessageReceiver @@ -269,7 +276,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(test_UDPv4Tests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(test_UDPv4Tests GTest::gtest ${MOCKS}) if(MSVC OR MSVC_IDE) target_link_libraries(test_UDPv4Tests ${PRIVACY} iphlpapi Shlwapi) else() @@ -279,9 +286,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) set(TRANSPORT_XFAIL_LIST ${TRANSPORT_XFAIL_LIST} XFAIL_TEST_UDP4) add_executable(TCPv4Tests ${TCPV4TESTS_SOURCE}) - target_compile_definitions(TCPv4Tests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(TCPv4Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(TCPv4Tests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/dds/QosPolicies ${PROJECT_SOURCE_DIR}/test/mock/rtps/MessageReceiver @@ -289,7 +299,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) - target_link_libraries(TCPv4Tests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(TCPv4Tests GTest::gtest ${MOCKS} $<$:OpenSSL::SSL$OpenSSL::Crypto>) if(MSVC OR MSVC_IDE) target_link_libraries(TCPv4Tests ${PRIVACY} fastcdr iphlpapi Shlwapi) @@ -303,17 +313,19 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(SharedMemTests ${SHAREDMEMTESTS_SOURCE}) target_compile_definitions(SharedMemTests PRIVATE FASTRTPS_NO_LIB - $<$:_ENABLE_ATOMIC_ALIGNMENT_FIX>) + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + $<$:_ENABLE_ATOMIC_ALIGNMENT_FIX>) target_include_directories(SharedMemTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/MessageReceiver ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReceiverResource ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ${THIRDPARTY_BOOST_INCLUDE_DIR} ) - target_link_libraries(SharedMemTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(SharedMemTests GTest::gtest ${MOCKS} $<$:OpenSSL::SSL$OpenSSL::Crypto> ${THIRDPARTY_BOOST_LINK_LIBS}) if(MSVC OR MSVC_IDE) diff --git a/test/unittest/utils/CMakeLists.txt b/test/unittest/utils/CMakeLists.txt index 91c14bdb92a..83cb12cb7a7 100644 --- a/test/unittest/utils/CMakeLists.txt +++ b/test/unittest/utils/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() @@ -43,9 +40,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(StringMatchingTests ${STRINGMATCHINGTESTS_SOURCE}) target_compile_definitions(StringMatchingTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(StringMatchingTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(StringMatchingTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(StringMatchingTests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(StringMatchingTests GTest::gtest ${MOCKS}) if(MSVC OR MSVC_IDE) target_link_libraries(StringMatchingTests ${PRIVACY} iphlpapi Shlwapi ) @@ -55,25 +52,25 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(FixedSizeStringTests ${FIXEDSIZESTRINGTESTS_SOURCE}) target_compile_definitions(FixedSizeStringTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(FixedSizeStringTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(FixedSizeStringTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(FixedSizeStringTests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(FixedSizeStringTests GTest::gtest ${MOCKS}) add_gtest(FixedSizeStringTests SOURCES ${FIXEDSIZESTRINGTESTS_SOURCE}) add_executable(BitmapRangeTests ${BITMAPRANGETESTS_SOURCE}) target_compile_definitions(BitmapRangeTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(BitmapRangeTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(BitmapRangeTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(BitmapRangeTests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(BitmapRangeTests GTest::gtest ${MOCKS}) add_gtest(BitmapRangeTests SOURCES ${BITMAPRANGETESTS_SOURCE}) add_executable(ResourceLimitedVectorTests ${RESOURCELIMITEDVECTORTESTS_SOURCE}) target_compile_definitions(ResourceLimitedVectorTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(ResourceLimitedVectorTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(ResourceLimitedVectorTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(ResourceLimitedVectorTests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(ResourceLimitedVectorTests GTest::gtest ${MOCKS}) add_gtest(ResourceLimitedVectorTests SOURCES ${RESOURCELIMITEDVECTORTESTS_SOURCE}) endif() endif() diff --git a/test/unittest/xmlparser/CMakeLists.txt b/test/unittest/xmlparser/CMakeLists.txt index 7c6c8a3be57..5576269e3e1 100644 --- a/test/unittest/xmlparser/CMakeLists.txt +++ b/test/unittest/xmlparser/CMakeLists.txt @@ -13,11 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - check_gmock() - - if(GTEST_FOUND AND GMOCK_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions( -D_WIN32_WINNT=0x0601 @@ -121,7 +117,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(XMLProfileParserTests ${XMLPROFILEPARSER_SOURCE}) target_compile_definitions(XMLProfileParserTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(XMLProfileParserTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/Log ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPTransportDescriptor ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPv4TransportDescriptor @@ -132,7 +127,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/test/mock/rtps/SharedMemTransportDescriptor ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(XMLProfileParserTests ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} + target_link_libraries(XMLProfileParserTests GTest::gmock $<$:iphlpapi$Shlwapi> $<$:ws2_32> ${TINYXML2_LIBRARY} @@ -197,7 +192,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(XMLParserTests ${XMLPARSER_SOURCE}) target_compile_definitions(XMLParserTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(XMLParserTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPTransportDescriptor ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPv4TransportDescriptor ${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPv6TransportDescriptor @@ -209,7 +203,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_BINARY_DIR}/include ) - target_link_libraries(XMLParserTests ${GTEST_LIBRARIES} + target_link_libraries(XMLParserTests GTest::gtest $<$:iphlpapi$Shlwapi> $<$:ws2_32> ${TINYXML2_LIBRARY} diff --git a/test/unittest/xtypes/CMakeLists.txt b/test/unittest/xtypes/CMakeLists.txt index c60f6e1942e..6cf3795fe98 100644 --- a/test/unittest/xtypes/CMakeLists.txt +++ b/test/unittest/xtypes/CMakeLists.txt @@ -13,10 +13,7 @@ # limitations under the License. if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) - include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake) - check_gtest() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions( -D_WIN32_WINNT=0x0601 @@ -24,8 +21,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) endif() - include_directories(${ASIO_INCLUDE_DIR}) - set(XTYPES_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicData.cpp @@ -70,12 +65,15 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) include_directories(mock/) add_executable(XTypesTests ${XTYPES_TEST_SOURCE}) - target_compile_definitions(XTypesTests PRIVATE FASTRTPS_NO_LIB) + target_compile_definitions(XTypesTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) target_include_directories(XTypesTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) - target_link_libraries(XTypesTests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(XTypesTests GTest::gtest ${MOCKS}) if(MSVC OR MSVC_IDE) target_link_libraries(XTypesTests ${PRIVACY} fastcdr iphlpapi Shlwapi ws2_32) else() diff --git a/test/xtypes/CMakeLists.txt b/test/xtypes/CMakeLists.txt index 245ba96c8cb..b797efdfcf6 100644 --- a/test/xtypes/CMakeLists.txt +++ b/test/xtypes/CMakeLists.txt @@ -76,10 +76,7 @@ macro(add_xtypes_gtest test) endmacro() 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 @@ -87,15 +84,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) ) endif() - add_definitions( - -DEPROSIMA_SHAPES_DLL_EXPORT - -DBUILD_SHARED_LIBS - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE - ) - - include_directories(${ASIO_INCLUDE_DIR}) - ############################################################################### # Unit tests ############################################################################### @@ -108,8 +96,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) ) add_executable(XTypesBlackBoxTests ${XTYPES_TESTS_SOURCE}) - target_include_directories(XTypesBlackBoxTests PRIVATE ${GTEST_INCLUDE_DIRS}) - target_link_libraries(XTypesBlackBoxTests fastrtps fastcdr ${GTEST_LIBRARIES}) + target_compile_definitions(XTypesBlackBoxTests PRIVATE + EPROSIMA_SHAPES_DLL_EXPORT + BUILD_SHARED_LIBS + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ) + target_include_directories(XTypesBlackBoxTests PRIVATE ${Asio_INCLUDE_DIR}) + target_link_libraries(XTypesBlackBoxTests fastrtps fastcdr GTest::gtest) add_xtypes_gtest(XTypesBlackBoxTests SOURCES ${XTYPES_TESTS_SOURCE}) endif() endif()