2015-08-31 61 views
2

我嘗試用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++") 

我這樣做,在我的項目的開頭只是打電話的「項目」命令。 但我得到一個無限循環當我打電話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版本,並且問題不會出現。

+1

你嘗試完全乾淨的配置(調用'cmake'空編譯目錄)?我不確定,但編譯器相關的變量不僅可以存儲在緩存中,所以緩存空虛不會保證整潔的配置。 – Tsyvarev

+0

是的,我做過。我找到了解決方案並將編輯第一篇文章。謝謝 –

回答

1

解決方案非常簡單:您需要使用cmake 2.8.9版,並且問題不會出現。

0

既然這是Google對我的第一個結果,我想我會爲Quentin提供一個備用解決方案。

如果調用-DCMAKE_TOOLCHAIN_FILE = toolchain.cmake您cmake的命令,你就可以把你的CMAKE_C_COMPILER和CMAKE_CXX_COMPILER覆蓋在新toolchain.cmake文件,cmake的將正常加載覆蓋沒有無限循環。

此解決方案爲那些無法輕鬆升級cmake的用戶提供了一個修補程序(例如,如果您是非root用戶和非sudo用戶),那些只想避免升級軟件包或管理其他軟件包,或那些不想打擾他們的系統管理員的人。此外,toolchain.cmake文件仍然可以執行邏輯來查找適當的或最新的devtoolset,如果您希望它動態選擇它。

此解決方案對於那些不會或不能將-DCMAKE_TOOLCHAIN_FILE參數添加到cmake調用的用戶不起作用。