gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:11:48 26 4
gpt4 key购买 nike

我尝试使用 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++")

我在项目开始时调用“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++

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

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

最佳答案

原因可能是其他cmake模块更改了您设置的变量。所以找到cmake代码并将其放在命令之前(SET(CMAKE_CXX_COMPILER“/opt/rh/devtoolset-2/root/usr/bin/g++”)),应该可以解决。

我遇到 pybind11 子模块的问题如下

SET(CMAKE_C_COMPILER /usr/bin/gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/g++)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")

add_subdirectory(pybind11)

解决方案将其更改为:

add_subdirectory(pybind11)

SET(CMAKE_C_COMPILER /usr/bin/gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/g++)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")

关于cmake - 使用 cmake 更改编译器会导致无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32306648/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com