使用 cmake 更改编译器会导致无限循环

Que*_*rod 9 g++ cmake

我尝试使用 cmake 更改编译器:

SET(CMAKE_C_COMPILER   "/opt/rh/devtoolset-2/root/usr/bin/gcc")
SET(CMAKE_CXX_COMPILER "/opt/rh/devtoolset-2/root/usr/bin/g++")
Run Code Online (Sandbox Code Playgroud)

我在项目开始时调用“PROJECT”命令之前执行此操作。但是当我调用 cmake 时出现无限循环,我有以下输出:

-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/gcc
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/rh/devtoolset-2/root/usr/bin/g++
-- Check for working CXX compiler: /opt/rh/devtoolset-2/root/usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Doxygen: /usr/bin/doxygen (found version "1.6.1") 
-- Looking for C++ include tut.h
-- Looking for C++ include tut.h - found
-- [STATUS] Found tut.h
-- 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/c++
CMAKE_CXX_COMPILER= /usr/bin/c++
Run Code Online (Sandbox Code Playgroud)

所以我在无限循环中一次又一次地收到此消息,即使我在调用 cmake 之前删除了缓存...

编辑:解决方案非常简单:您需要使用 cmake 版本 2.8.9 并且问题不会出现。

Que*_*rod -1

解决方案非常简单:您需要使用 cmake 版本 2.8.9 并且不会出现问题。

  • 不是真正的答案。我刚刚在 3.18.1 中遇到了这个问题 (2认同)