修改gtest的编译器



我试图在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 run命令中设置编译器来解决这个问题:

cmake -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++ ..

相关内容

  • 没有找到相关文章

最新更新