From 4f9f7e98e2d108e6b74ece18becfbbd0134d0723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Fri, 9 Jul 2021 08:12:14 +0200 Subject: [PATCH] Support of googletest using colcon [12009] (#2054) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #11961. New support of googletest using colcon Signed-off-by: Ricardo González * Refs #11961. Fix compilation errors Signed-off-by: Ricardo González * Refs #11961. Fix compilation error Signed-off-by: Ricardo González * Refs #11961. Including asio in a good way Signed-off-by: Ricardo González * Refs #11961. gmock exports gtest Signed-off-by: Ricardo González * Refs #11961. Forget to remove one include_directories Signed-off-by: Ricardo González * Refs #11961. Little change Signed-off-by: Ricardo González * Refs #11961. Fix error Signed-off-by: Ricardo González --- cmake/common/gtest.cmake | 60 -------- cmake/modules/FindGMock.cmake | 130 ------------------ colcon.pkg | 4 +- .../C++/DDS/DeadlineQoSExample/CMakeLists.txt | 10 +- .../C++/DeadlineQoSExample/CMakeLists.txt | 10 +- test/CMakeLists.txt | 9 +- test/blackbox/CMakeLists.txt | 34 ++--- test/communication/CMakeLists.txt | 25 ++-- test/performance/CMakeLists.txt | 7 - test/performance/latency/CMakeLists.txt | 4 + test/performance/throughput/CMakeLists.txt | 5 +- test/performance/video/CMakeLists.txt | 6 +- test/profiling/CMakeLists.txt | 12 +- test/realtime/CMakeLists.txt | 6 +- .../mutex_testing_tool/CMakeLists.txt | 10 +- test/unittest/CMakeLists.txt | 5 - test/unittest/dds/collections/CMakeLists.txt | 9 +- .../dds/core/condition/CMakeLists.txt | 9 +- test/unittest/dds/core/entity/CMakeLists.txt | 9 +- 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 | 25 ++-- test/unittest/logging/CMakeLists.txt | 13 +- .../logging/log_macros/CMakeLists.txt | 29 ++-- 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 | 14 +- test/unittest/rtps/history/CMakeLists.txt | 26 ++-- test/unittest/rtps/network/CMakeLists.txt | 13 +- test/unittest/rtps/persistence/CMakeLists.txt | 9 +- test/unittest/rtps/reader/CMakeLists.txt | 11 +- .../rtps/resources/timedevent/CMakeLists.txt | 13 +- test/unittest/rtps/security/CMakeLists.txt | 15 +- test/unittest/rtps/writer/CMakeLists.txt | 37 +++-- .../security/accesscontrol/CMakeLists.txt | 14 +- .../security/authentication/CMakeLists.txt | 13 +- .../security/cryptography/CMakeLists.txt | 8 +- test/unittest/security/logging/CMakeLists.txt | 8 +- test/unittest/statistics/dds/CMakeLists.txt | 29 ++-- test/unittest/statistics/rtps/CMakeLists.txt | 11 +- test/unittest/transport/CMakeLists.txt | 43 +++--- test/unittest/utils/CMakeLists.txt | 33 ++--- test/unittest/xmlparser/CMakeLists.txt | 18 +-- test/unittest/xtypes/CMakeLists.txt | 13 +- test/xtypes/CMakeLists.txt | 22 +-- 49 files changed, 280 insertions(+), 610 deletions(-) delete mode 100644 cmake/modules/FindGMock.cmake diff --git a/cmake/common/gtest.cmake b/cmake/common/gtest.cmake index 283884598c4..08d8102f2cf 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 7b64bc1601c..df93ad6258e 100644 --- a/examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt +++ b/examples/C++/DDS/DeadlineQoSExample/CMakeLists.txt @@ -50,18 +50,14 @@ 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 $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) +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 ad0a6273fbb..2e6e92494d5 100644 --- a/examples/C++/DeadlineQoSExample/CMakeLists.txt +++ b/examples/C++/DeadlineQoSExample/CMakeLists.txt @@ -50,18 +50,14 @@ 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 $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) +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 9d7a18c7e78..c6e85d654e2 100644 --- a/test/blackbox/CMakeLists.txt +++ b/test/blackbox/CMakeLists.txt @@ -158,10 +158,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 @@ -169,13 +166,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 ############################################################################### @@ -200,13 +190,15 @@ 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 $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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") @@ -270,14 +262,16 @@ 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 $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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}" @@ -307,14 +301,16 @@ 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 $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 5545afcdd73..8686d1219e2 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 ############################################################################### @@ -37,10 +30,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) ) add_executable(SimpleCommunicationPublisher ${PUBLISHER_SOURCE}) target_compile_definitions(SimpleCommunicationPublisher PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(SimpleCommunicationPublisher PRIVATE ${PROJECT_SOURCE_DIR}/test/blackbox) + 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} @@ -49,10 +46,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) ) add_executable(SimpleCommunicationSubscriber ${SUBSCRIBER_SOURCE}) target_compile_definitions(SimpleCommunicationSubscriber PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(SimpleCommunicationSubscriber PRIVATE ${PROJECT_SOURCE_DIR}/test/blackbox) + 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} @@ -63,10 +64,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) add_executable(SimpleCommunicationPubSub ${PUBSUB_SOURCE}) target_compile_definitions(SimpleCommunicationPubSub PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(SimpleCommunicationPubSub PRIVATE ${PROJECT_SOURCE_DIR}/test/blackbox) + 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 2c699ac6e4e..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 b5010ad8fe3..d7aed2c9c0c 100644 --- a/test/performance/latency/CMakeLists.txt +++ b/test/performance/latency/CMakeLists.txt @@ -24,10 +24,14 @@ set( add_executable(LatencyTest ${LATENCYTEST_SOURCE}) target_compile_definitions(LatencyTest PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) +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 d778f5c25db..f5d0ea5d0ea 100644 --- a/test/performance/throughput/CMakeLists.txt +++ b/test/performance/throughput/CMakeLists.txt @@ -24,11 +24,14 @@ set( add_executable(ThroughputTest ${THROUGHPUTTEST_SOURCE}) target_compile_definitions(ThroughputTest PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) -target_include_directories(ThroughputTest PRIVATE) +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 f206be797db..791cb11a2bf 100644 --- a/test/performance/video/CMakeLists.txt +++ b/test/performance/video/CMakeLists.txt @@ -77,8 +77,10 @@ if(GST_FOUND) main_VideoTest.cpp ) add_executable(VideoTest ${VIDEOTEST_SOURCE}) - + target_compile_definitions(VideoTest PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) @@ -88,12 +90,14 @@ if(GST_FOUND) 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 b042b99b224..979942f23fa 100644 --- a/test/profiling/CMakeLists.txt +++ b/test/profiling/CMakeLists.txt @@ -17,6 +17,8 @@ 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> $<$>,$>:__DEBUG> @@ -24,18 +26,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) else() target_compile_definitions(${PROJECT_NAME} PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) endif() - add_definitions( - -DBOOST_ASIO_STANDALONE - -DASIO_STANDALONE - ) - - include_directories(${Asio_INCLUDE_DIR}) - ############################################################################### # Binaries ############################################################################### @@ -45,6 +42,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 0c1e47b4bff..fec4fb33c9b 100644 --- a/test/realtime/CMakeLists.txt +++ b/test/realtime/CMakeLists.txt @@ -1,7 +1,6 @@ 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}) @@ -9,8 +8,7 @@ if(GTEST_FOUND) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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..fc00cb1db0c 100644 --- a/test/realtime/mutex_testing_tool/CMakeLists.txt +++ b/test/realtime/mutex_testing_tool/CMakeLists.txt @@ -12,18 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -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 +27,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 0a653011dc4..68f63390d5b 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/collections/CMakeLists.txt b/test/unittest/dds/collections/CMakeLists.txt index e6f8374cdb5..6c3d7c84e4b 100644 --- a/test/unittest/dds/collections/CMakeLists.txt +++ b/test/unittest/dds/collections/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() @@ -33,9 +30,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LoanableSequenceTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LoanableSequenceTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LoanableSequenceTests ${GTEST_LIBRARIES}) + target_link_libraries(LoanableSequenceTests GTest::gtest) add_gtest(LoanableSequenceTests SOURCES ${LOANABLE_SEQUENCE_TESTS_SOURCE}) endif() endif() diff --git a/test/unittest/dds/core/condition/CMakeLists.txt b/test/unittest/dds/core/condition/CMakeLists.txt index 80301017f9c..3e8443754f9 100644 --- a/test/unittest/dds/core/condition/CMakeLists.txt +++ b/test/unittest/dds/core/condition/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() @@ -37,9 +34,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(ConditionTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(ConditionTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(ConditionTests ${GTEST_LIBRARIES} fastcdr) + target_link_libraries(ConditionTests GTest::gtest fastcdr) add_gtest(ConditionTests SOURCES ${CONDITION_TESTS_SOURCE}) endif() endif() diff --git a/test/unittest/dds/core/entity/CMakeLists.txt b/test/unittest/dds/core/entity/CMakeLists.txt index 65a152bfe49..d0ae6eec3f3 100644 --- a/test/unittest/dds/core/entity/CMakeLists.txt +++ b/test/unittest/dds/core/entity/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() @@ -36,9 +33,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(EntityTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(EntityTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(EntityTests ${GTEST_LIBRARIES} fastcdr) + target_link_libraries(EntityTests GTest::gtest fastcdr) add_gtest(EntityTests SOURCES ${ENTITY_TESTS_SOURCE}) endif() endif() diff --git a/test/unittest/dds/participant/CMakeLists.txt b/test/unittest/dds/participant/CMakeLists.txt index 235ac604ba6..a09b9737d1d 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 @@ -37,13 +33,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 8844463cbbc..5d7352c87b2 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 @@ -43,13 +39,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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}) @@ -58,13 +53,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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} ENVIRONMENTS "CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs") diff --git a/test/unittest/dds/status/CMakeLists.txt b/test/unittest/dds/status/CMakeLists.txt index 14c593a8e7c..714803d32ce 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 @@ -131,7 +127,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) target_include_directories(ListenerTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/DataSharingPayloadPool ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader @@ -166,8 +161,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}) if(MSVC OR MSVC_IDE) target_link_libraries(ListenerTests iphlpapi Shlwapi ws2_32) endif() diff --git a/test/unittest/dds/subscriber/CMakeLists.txt b/test/unittest/dds/subscriber/CMakeLists.txt index 378e6a76968..b24e4e81b6d 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 @@ -37,13 +33,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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}) @@ -52,13 +47,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 c1a9436ef02..11ae861696d 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() @@ -36,13 +32,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 e597eccaf4f..4217597f7b7 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 @@ -106,11 +101,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(DynamicTypesTests ${DYNAMIC_TYPES_TEST_SOURCE}) target_compile_definitions(DynamicTypesTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -121,7 +118,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} @@ -132,13 +129,15 @@ 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 + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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} @@ -149,13 +148,15 @@ 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 + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 a34d1f50ccb..9566f0fdc15 100644 --- a/test/unittest/logging/CMakeLists.txt +++ b/test/unittest/logging/CMakeLists.txt @@ -15,10 +15,7 @@ add_subdirectory(log_macros) 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)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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}) @@ -71,9 +68,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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/logging/log_macros/CMakeLists.txt b/test/unittest/logging/log_macros/CMakeLists.txt index 24b63c70c03..6e961b50d32 100644 --- a/test/unittest/logging/log_macros/CMakeLists.txt +++ b/test/unittest/logging/log_macros/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,9 +37,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LogMacrosAllActiveTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogMacrosAllActiveTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogMacrosAllActiveTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogMacrosAllActiveTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ) add_gtest(LogMacrosAllActiveTests SOURCES ${LOGMACROS_ALL_TEST_SOURCE}) @@ -60,9 +57,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LogMacrosNoInfoTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogMacrosNoInfoTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogMacrosNoInfoTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogMacrosNoInfoTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ) add_gtest(LogMacrosNoInfoTests SOURCES ${LOGMACROS_NOINFO_TEST_SOURCE}) @@ -80,9 +77,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LogMacrosNoWarningTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogMacrosNoWarningTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogMacrosNoWarningTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogMacrosNoWarningTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ) add_gtest(LogMacrosNoWarningTests SOURCES ${LOGMACROS_NOWARNING_TEST_SOURCE}) @@ -100,9 +97,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LogMacrosNoErrorTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogMacrosNoErrorTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogMacrosNoErrorTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogMacrosNoErrorTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ) add_gtest(LogMacrosNoErrorTests SOURCES ${LOGMACROS_NOERROR_TEST_SOURCE}) @@ -120,9 +117,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LogMacrosDefaultTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogMacrosDefaultTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogMacrosDefaultTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogMacrosDefaultTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ) add_gtest(LogMacrosDefaultTests SOURCES ${LOGMACROS_DEFAULT_TEST_SOURCE}) @@ -142,9 +139,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LogMacrosInternalDebugOffTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LogMacrosInternalDebugOffTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LogMacrosInternalDebugOffTests ${GTEST_LIBRARIES} ${MOCKS} + target_link_libraries(LogMacrosInternalDebugOffTests GTest::gtest ${MOCKS} $<$:iphlpapi$Shlwapi> ) add_gtest(LogMacrosInternalDebugOffTests SOURCES ${LOGMACROS_INTERNALDEBUG_TEST_SOURCE}) diff --git a/test/unittest/rtps/builtin/CMakeLists.txt b/test/unittest/rtps/builtin/CMakeLists.txt index a15a960a3f6..56d6a29ddb0 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 @@ -74,14 +70,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 1d21ddb2c1a..558c6f13916 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 @@ -39,9 +36,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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}) @@ -50,10 +47,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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() @@ -64,9 +60,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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}) @@ -74,9 +70,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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 17ee9a6c104..2f0441d73c4 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 @@ -69,7 +65,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -88,8 +83,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 808834a8a03..81fdbb3f51e 100644 --- a/test/unittest/rtps/flowcontrol/CMakeLists.txt +++ b/test/unittest/rtps/flowcontrol/CMakeLists.txt @@ -13,16 +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() - - if(GTEST_FOUND) + if(GTest_FOUND) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() - include_directories(${Asio_INCLUDE_DIR}) - set(THROUGHPUTCONTROLLERTESTS_SOURCE ThroughputControllerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowController.cpp @@ -32,10 +27,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(ThroughputControllerTests ${THROUGHPUTCONTROLLERTESTS_SOURCE}) target_compile_definitions(ThroughputControllerTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(ThroughputControllerTests PRIVATE ${GTEST_INCLUDE_DIRS} + 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 @@ -44,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::gtest 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 616ece50fa2..198da01a287 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 @@ -66,15 +62,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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}) @@ -83,12 +78,11 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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}) @@ -97,12 +91,11 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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}) @@ -111,13 +104,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 3fb446b1ac4..6fff501ff82 100644 --- a/test/unittest/rtps/network/CMakeLists.txt +++ b/test/unittest/rtps/network/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(NETWORKFACTORYTESTS_SOURCE NetworkFactoryTests.cpp mock/MockTransport.cpp @@ -76,11 +71,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(NetworkFactoryTests ${NETWORKFACTORYTESTS_SOURCE}) target_compile_definitions(NetworkFactoryTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -89,7 +86,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 1350f5a4405..d836cec7c9c 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 @@ -35,13 +32,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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} + GTest::gtest ${CMAKE_DL_LIBS} ) if(MSVC OR MSVC_IDE) diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index ef920d94408..fa8569cf3dd 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 @@ -39,7 +35,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -55,8 +50,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 7c4a3dde696..8b124336466 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 @@ -40,16 +35,18 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(TimedEventTests ${TIMEDEVENTTESTS_SOURCE}) target_compile_definitions(TimedEventTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 2dc54237642..303ce22b233 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 @@ -62,11 +56,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) endif() target_compile_definitions(SecurityAuthentication PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -90,8 +86,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 ee609cf67fe..5f31e86a94c 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,15 +30,15 @@ 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 + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -61,8 +55,8 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${THIRDPARTY_BOOST_INCLUDE_DIR} ) target_link_libraries(ReaderProxyTests - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} foonathan_memory - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} + GTest::gmock foonathan_memory + ${CMAKE_DL_LIBS} ${THIRDPARTY_BOOST_LINK_LIBS}) add_gtest(ReaderProxyTests SOURCES ${WRITERPROXYTESTS_SOURCE}) @@ -82,19 +76,19 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ) add_executable(LivelinessManagerTests ${LIVELINESSMANAGERTESTS_SOURCE}) target_compile_definitions(LivelinessManagerTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) target_include_directories(LivelinessManagerTests PRIVATE - ${GTEST_INCLUDE_DIRS} - ${GMOCK_INCLUDE_DIRS} + ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) target_link_libraries(LivelinessManagerTests PRIVATE - ${GTEST_LIBRARIES} - ${GMOCK_LIBRARIES}) + GTest::gmock) add_gtest(LivelinessManagerTests SOURCES ${LIVELINESSMANAGERTESTS_SOURCE}) # RTPSWriter @@ -103,15 +97,16 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(RTPSWriterTests ${RTPSWRITERTESTS_SOURCE}) target_compile_definitions(RTPSWriterTests PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) target_include_directories(RTPSWriterTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} - ) + ${Asio_INCLUDE_DIR}) target_link_libraries(RTPSWriterTests fastrtps foonathan_memory - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + GTest::gmock + ${CMAKE_DL_LIBS}) add_gtest(RTPSWriterTests SOURCES ${RTPSWRITERTESTS_SOURCE}) endif() diff --git a/test/unittest/security/accesscontrol/CMakeLists.txt b/test/unittest/security/accesscontrol/CMakeLists.txt index 94a07a831de..5772cbce207 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 @@ -71,12 +66,14 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${CMAKE_CURRENT_SOURCE_DIR}/AccessControlTests.cpp) target_compile_definitions(AccessControlTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -90,7 +87,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 243484f4973..f080818e689 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 @@ -56,17 +51,19 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BuiltinPKIDHTests.cpp) target_compile_definitions(BuiltinPKIDH PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 24768461aa4..26f02465262 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() @@ -49,12 +46,11 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 69edbb31f59..57b38746076 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() @@ -43,11 +40,10 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index 52db3e1270b..b53dd58fc28 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/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) add_definitions(-DNOMINMAX) @@ -33,9 +30,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNAL_DEBUG> # Internal debug activated. ) - target_include_directories(StatisticsDomainParticipantTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(StatisticsDomainParticipantTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp) - target_link_libraries(StatisticsDomainParticipantTests fastrtps fastcdr ${GTEST_LIBRARIES}) + target_link_libraries(StatisticsDomainParticipantTests fastrtps fastcdr GTest::gtest) add_gtest(StatisticsDomainParticipantTests SOURCES ${STATISTICS_DOMAINPARTICIPANT_TESTS_SOURCE}) ## StatisticsQosTests @@ -47,13 +44,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNAL_DEBUG> # Internal debug activated. ) - target_include_directories(StatisticsQosTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(StatisticsQosTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp) - target_link_libraries(StatisticsQosTests fastrtps fastcdr ${GTEST_LIBRARIES}) + target_link_libraries(StatisticsQosTests fastrtps fastcdr GTest::gtest) add_gtest(StatisticsQosTests SOURCES ${STATISTICS_QOS_TESTS_SOURCE}) ## StatisticsDomainParticipantListenerTests - if (GMOCK_FOUND AND FASTDDS_STATISTICS) + if (FASTDDS_STATISTICS) set(DOMAINPARTICIPANTSTATISTICSLISTENER_TESTS_SOURCE DomainParticipantStatisticsListenerTests.cpp) @@ -69,19 +66,18 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNAL_DEBUG> # Internal debug activated. ) target_include_directories(DomainParticipantStatisticsListenerTests PRIVATE - ${GTEST_INCLUDE_DIRS} DomainParticipantStatisticsListenerTests/mock ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp) target_link_libraries(DomainParticipantStatisticsListenerTests - fastcdr ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ) + fastcdr GTest::gmock ) add_gtest(DomainParticipantStatisticsListenerTests SOURCES ${DOMAINPARTICIPANTSTATISTICSLISTENER_TESTS_SOURCE}) endif() ## StatisticsDomainParticipantMockTests - if (GMOCK_FOUND AND SQLITE3_SUPPORT AND FASTDDS_STATISTICS) + if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS) set(STATISTICS_DOMAINPARTICIPANT_MOCK_TESTS_SOURCE StatisticsDomainParticipantMockTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationDescriptor.cpp @@ -322,8 +318,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:STDOUTERR_LOG_CONSUMER> # Enable StdoutErrConsumer as default LogConsumer ) target_include_directories(StatisticsDomainParticipantMockTests PRIVATE - ${GTEST_INCLUDE_DIRS} - ${GMOCK_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} StatisticsDomainParticipantMockTests/mock/ ${PROJECT_SOURCE_DIR}/test/mock/dds/Publisher/ @@ -335,10 +329,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${THIRDPARTY_BOOST_INCLUDE_DIR}) target_link_libraries(StatisticsDomainParticipantMockTests ${PRIVACY} fastcdr - foonathan_memory - ${GTEST_LIBRARIES} - ${GMOCK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} + foonathan_memory + GTest::gmock + ${CMAKE_DL_LIBS} ${TINYXML2_LIBRARY} $<$:OpenSSL::SSL$OpenSSL::Crypto> $<$:iphlpapi$Shlwapi> diff --git a/test/unittest/statistics/rtps/CMakeLists.txt b/test/unittest/statistics/rtps/CMakeLists.txt index 7d6225fd080..425e2821f44 100644 --- a/test/unittest/statistics/rtps/CMakeLists.txt +++ b/test/unittest/statistics/rtps/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() @@ -29,18 +26,20 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(RTPSStatisticsTests ${STATISTICS_RTPS_TESTS_SOURCE}) target_compile_definitions(RTPSStatisticsTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNAL_DEBUG> # Internal debug activated. ) - target_include_directories(RTPSStatisticsTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(RTPSStatisticsTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ${Asio_INCLUDE_DIR} ) - target_link_libraries(RTPSStatisticsTests fastrtps fastcdr ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES}) + target_link_libraries(RTPSStatisticsTests fastrtps fastcdr GTest::gtest GTest::gmock) add_gtest(RTPSStatisticsTests SOURCES ${STATISTICS_RTPS_TESTS_SOURCE}) endif() diff --git a/test/unittest/transport/CMakeLists.txt b/test/unittest/transport/CMakeLists.txt index 8cc8165b5a8..1519272f187 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,17 +197,19 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(UDPv4Tests ${UDPV4TESTS_SOURCE}) target_compile_definitions(UDPv4Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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() @@ -224,17 +221,19 @@ 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 + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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() @@ -243,11 +242,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(TCPv6Tests ${TCPV6TESTS_SOURCE}) target_compile_definitions(TCPv6Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -255,7 +256,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) @@ -268,11 +269,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(test_UDPv4Tests ${TEST_UDPV4TESTS_SOURCE}) target_compile_definitions(test_UDPv4Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -280,7 +283,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() @@ -291,11 +294,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(TCPv4Tests ${TCPV4TESTS_SOURCE}) target_compile_definitions(TCPv4Tests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -303,7 +308,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) @@ -317,20 +322,22 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(SharedMemTests ${SHAREDMEMTESTS_SOURCE}) target_compile_definitions(SharedMemTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$:_ENABLE_ATOMIC_ALIGNMENT_FIX> $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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} eProsima_atomic diff --git a/test/unittest/utils/CMakeLists.txt b/test/unittest/utils/CMakeLists.txt index dfb3777d7f6..2b5790d6988 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() @@ -61,9 +58,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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 ) @@ -76,9 +73,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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}) @@ -87,9 +84,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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}) @@ -98,9 +95,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - 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}) add_executable(LocatorTests ${LOCATORTESTS_SOURCE}) @@ -108,24 +105,24 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(LocatorTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(LocatorTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - target_link_libraries(LocatorTests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(LocatorTests GTest::gtest ${MOCKS}) add_gtest(LocatorTests SOURCES ${LOCATORTESTS_SOURCE}) add_executable(FixedSizeQueueTests ${FIXEDSIZEQUEUETESTS_SOURCE}) target_compile_definitions(FixedSizeQueueTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(FixedSizeQueueTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(FixedSizeQueueTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_BINARY_DIR}/include) - target_link_libraries(FixedSizeQueueTests ${GTEST_LIBRARIES} ${MOCKS}) + target_link_libraries(FixedSizeQueueTests GTest::gtest ${MOCKS}) add_gtest(FixedSizeQueueTests SOURCES ${FIXEDSIZEQUEUETESTS_SOURCE}) add_executable(SystemInfoTests ${SYSTEMINFOTESTS_SOURCE}) target_compile_definitions(SystemInfoTests PRIVATE FASTRTPS_NO_LIB) - target_include_directories(SystemInfoTests PRIVATE ${GTEST_INCLUDE_DIRS} + target_include_directories(SystemInfoTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_BINARY_DIR}/include) - target_link_libraries(SystemInfoTests ${GTEST_LIBRARIES}) + target_link_libraries(SystemInfoTests GTest::gtest) add_gtest(SystemInfoTests SOURCES ${SYSTEMINFOTESTS_SOURCE}) endif() diff --git a/test/unittest/xmlparser/CMakeLists.txt b/test/unittest/xmlparser/CMakeLists.txt index ac9a77772ca..41070ce2e33 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 @@ -127,7 +123,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -138,7 +133,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} @@ -212,7 +207,6 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 @@ -224,7 +218,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} @@ -248,12 +242,11 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) $<$:__INTERNALDEBUG> # Internal debug activated. ) target_include_directories(XMLTreeTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) - target_link_libraries(XMLTreeTests ${GTEST_LIBRARIES} + target_link_libraries(XMLTreeTests GTest::gtest $<$:iphlpapi$Shlwapi> $<$:ws2_32> ) @@ -322,14 +315,13 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(XMLEndpointParserTests ${XMLENDPOINTPARSERTESTS_SOURCE}) target_compile_definitions(XMLEndpointParserTests PRIVATE FASTRTPS_NO_LIB) target_include_directories(XMLEndpointParserTests PRIVATE - ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderProxyData ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterProxyData ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) - target_link_libraries(XMLEndpointParserTests ${GTEST_LIBRARIES} + target_link_libraries(XMLEndpointParserTests GTest::gtest $<$:iphlpapi$Shlwapi> $<$:ws2_32> ${TINYXML2_LIBRARY} diff --git a/test/unittest/xtypes/CMakeLists.txt b/test/unittest/xtypes/CMakeLists.txt index 5b6951614c3..11dd4cb41ef 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 @@ -71,14 +66,16 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) add_executable(XTypesTests ${XTYPES_TEST_SOURCE}) target_compile_definitions(XTypesTests PRIVATE FASTRTPS_NO_LIB + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) 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 406019b2a64..9f70a821146 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 ############################################################################### @@ -109,11 +97,15 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) add_executable(XTypesBlackBoxTests ${XTYPES_TESTS_SOURCE}) target_compile_definitions(XTypesBlackBoxTests PRIVATE + EPROSIMA_SHAPES_DLL_EXPORT + BUILD_SHARED_LIBS + BOOST_ASIO_STANDALONE + ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) - target_include_directories(XTypesBlackBoxTests PRIVATE ${GTEST_INCLUDE_DIRS}) - target_link_libraries(XTypesBlackBoxTests fastrtps fastcdr ${GTEST_LIBRARIES}) + 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()