проект использует googletest для модульного тестирования и включается в файл поиска CMake следующим образом:
Код: Выделить всё
# FindGTest.cmake
if (CMAKE_SYSTEM_NAME STREQUAL "TheTarget")
FetchContent_Declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0)
FetchContent_MakeAvailable(GTest)
else()
find_package(GTest CONFIG REQUIRED)
endif()
Код: Выделить всё
C:/dev/project/build/_deps/gtest-src/googletest/include\gtest/internal/gtest-port.h:2058:38: error: use of undeclared identifier 'isatty'
...
C:/dev/project/build/_deps/gtest-src/googletest/include\gtest/internal/gtest-port.h:2087:44: error: use of undeclared identifier 'chdir'
...
C:/dev/project/build/_deps/gtest-src/googletest/include\gtest/internal/gtest-port.h:2135:10: error: use of undeclared identifier 'getenv'; did you mean 'GetEnv'?
...
C:/dev/project/_deps/gtest-src/googletest\src/gtest-death-test.cc:1106:27: error: use of undeclared identifier 'pipe'
...
C:/dev/project/build/_deps/gtest-src/googletest\src/gtest-death-test.cc:1119:27: error: use of undeclared identifier 'fork'
...
C:/dev/project/build/_deps/gtest-src/googletest\src/gtest-death-test.cc:1204:3: error: use of undeclared identifier 'execv'
...
C:/dev/project/build/_deps/gtest-src/googletest\src/gtest-filepath.cc:115:18: error: use of undeclared identifier 'getcwd'
Есть ли способ сделать это, предоставив правильную комбинацию макросов в build (например, с помощью операторов CMake add_definition())?
Или мне нужно создать собственную версию gtest? Т.е. Я полагаю, это означает, что мне не следует использовать FetchContent_Declare()/
Код: Выделить всё
FetchContent_MakeAvailable()
Подробнее здесь: https://stackoverflow.com/questions/792 ... six-target