【发布时间】:2021-10-05 08:49:57
【问题描述】:
我正在尝试在我的 cmake 中为我的 gtest 设置编译器。
我首先使用 FetchContent 获取 gtest 代码。
要更改 FetchContent 中的编译器,我设置了 CMAKE_CXX_COMPILER(在此处回答:https://cmake.org/pipermail/cmake/2019-March/069206.html)
set(CMAKE_CXX_COMPILER "/usr/bin/arm-linux-gnueabihf-g++" CACHE INTERNAL "")
########################################
# Fetch gtests
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/release-1.11.0.zip
)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
########################################
第一个 cmake 构建成功(当没有 CMakeCache.txt 时)。但是第二个失败了:
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_CXX_COMPILER= /usr/bin/arm-linux-gnueabihf-g++
在那条错误消息之后,cmake 再次启动,但由于没有获得任何 cmake 参数而失败:
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at src/CMakeLists.txt:36 (message):
Please provide spi mode. -DSPI_MODE=[mock, asic]
-- Configuring incomplete, errors occurred!
See also "/work/build/arm/cmake/CMakeFiles/CMakeOutput.log".
设置 gtest 编译器的正确方法是什么?
【问题讨论】:
标签: cmake googletest