Я компилирую тестовый проект Google, и компиляция прошла успешно.Однако я получаю следующую ошибку во время связи с моим проектом.Интересно, это связано с тем, как упорядочены ссылки?
CMakeFiles/Test.dir/Test1.cpp.o: In function `GetTimeMock::GetTime(int*, _time_data*)':
Test1.cpp:(.text._ZN20GetTimeMock19ENET_GetTimeEPiP19_time_data[_ZN20EnetGetTimeMock19ENET_GetTimeEPiP19_time_data]+0x4a): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'
Вот как выглядит мой CMAKE
make_minimum_required(VERSION 3.2.2)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
# Set compiler to c++17
#set(CMAKE_CXX_STANDARD 17)
ExternalProject_Add(
GoogleTest
URL https://github.com/google/googletest/archive/6ce9b98f541b8bcd84c5c5b3483f29a933c4aefb.zip
URL_MD5 "0bca4c8c9fc2d06634185057a905ff11"
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external"
BUILD_COMMAND "$(MAKE)"
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -DNDEBUG -Wall -Wextra -pedantic")
set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../source)
set(UNIT_TEST_MAIN ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_test_main.cpp)
set(GTEST_MAIN ${CMAKE_BINARY_DIR}/external/lib/libgtest_main.a)
set(GTEST ${CMAKE_BINARY_DIR}/external/lib/libgtest.a)
set(GMOCK_MAIN ${CMAKE_BINARY_DIR}/external/lib/libgmock_main.a)
set(GMOCK ${CMAKE_BINARY_DIR}/external/lib/libgmock.a)
set(SOURCE
${UNIT_TEST_MAIN}
${SOURCE_PATH}test.cpp
${SOURCE_PATH}/test1.cpp
${SOURCE_PATH}/test2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bar1.cpp
${STUB_PATH}/platforms/k64f/src/fstub.cpp
)
include_directories(
${SOURCE_PATH}/include
${SOURCE_PATH}/Files
${SOURCE_PATH}/
)
set(target "Test")
add_definitions(${DEFINITION})
add_executable("${target}" ${SOURCE})
add_dependencies("${target}" GoogleTest)
target_link_libraries("${target}"
"${GMOCK_MAIN}"
"${GMOCK}"
"${GTEST_MAIN}"
"${GTEST}"
pthread)