diff --git a/cmake/dev/gtest.cmake b/cmake/dev/gtest.cmake index 772198f0ab7..025a3eb9156 100644 --- a/cmake/dev/gtest.cmake +++ b/cmake/dev/gtest.cmake @@ -21,6 +21,12 @@ macro(check_gtest) 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() @@ -45,6 +51,12 @@ macro(check_gmock) 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() diff --git a/test/mock/rtps/StatefulReader/fastrtps/rtps/reader/StatefulReader.h b/test/mock/rtps/StatefulReader/fastrtps/rtps/reader/StatefulReader.h index 962b312c394..bacbd8291aa 100644 --- a/test/mock/rtps/StatefulReader/fastrtps/rtps/reader/StatefulReader.h +++ b/test/mock/rtps/StatefulReader/fastrtps/rtps/reader/StatefulReader.h @@ -2,6 +2,7 @@ #define _RTPS_READER_STATEFULREADER_H_ #include +#include namespace eprosima { @@ -13,6 +14,9 @@ namespace eprosima { public: + // In real class, inherited from Endpoint base class. + inline const GUID_t& getGuid() const { return GUID_t(); }; + inline ReaderTimes& getTimes(){return m_times;}; private: diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index 8bc6e6c7590..91b8c29d74e 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -8,6 +8,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) set(WRITERPROXYTESTS_SOURCE WriterProxyTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/WriterProxy.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/log/Log.cpp ) if(WIN32) @@ -24,7 +25,7 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterProxyLiveliness ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}) target_link_libraries(WriterProxyTests ${Boost_LIBRARIES} - ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} + ${GMOCK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) endif() endif() diff --git a/test/unittest/rtps/reader/WriterProxyTests.cpp b/test/unittest/rtps/reader/WriterProxyTests.cpp index 2f302f5b57a..990b8a1751f 100644 --- a/test/unittest/rtps/reader/WriterProxyTests.cpp +++ b/test/unittest/rtps/reader/WriterProxyTests.cpp @@ -1,5 +1,5 @@ +#include #include -#include #define TEST_FRIENDS \ FRIEND_TEST(WriterProxyTests, MissingChangesUpdate); \ @@ -315,6 +315,6 @@ namespace eprosima int main(int argc, char **argv) { - testing::InitGoogleTest(&argc, argv); + testing::InitGoogleMock(&argc, argv); return RUN_ALL_TESTS(); }