0
我想檢查我的C++項目是否在GCC的舊版本上編譯。爲此,我安裝了舊版本,並希望CMake使用它來編譯我的項目。爲什麼CMake拒絕使用非默認編譯器?
CMake的常見問題on changing the compiler告訴我,這是做正確的方式:
CC=gcc-4.4 CXX=g++-4.4 cmake -G "Unix Makefiles" ..
原來這就是我輸入和CMake的似乎運行正常:
[email protected]:~/projects/myProject/build$ CC=gcc-4.4 CXX=g++-4.4 cmake -G "Unix Makefiles" .. -- Found PythonInterp: /usr/bin/python (found version "2.7.4") -- Looking for include file pthread.h -- Looking for include file pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Configuring done -- Generating done -- Build files have been written to: /home/chris/projects/myProject/build
然而,展望在CMakeCache.txt現在我發現這一點:
//CXX compiler. CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
顯然CMake的沒有使用補償我指定了。當我改變這一行使用G ++ - 4.4和再次運行CMake的它會創建一個無限循環:
[email protected]:~/projects/myProject/build$ CC=gcc-4.4 CXX=g++-4.4 cmake -G "Unix Makefiles" .. -- 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/g++-4.4 -- Found PythonInterp: /usr/bin/python (found version "2.7.4") -- Looking for include file pthread.h -- Looking for include file pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- 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/g++-4.4 -- Found PythonInterp: /usr/bin/python (found version "2.7.4") // and so on...
爲什麼CMake的不使用我指定的編譯器,我怎麼能解決這個問題?
謝謝你,我永遠只是刪除了CMakeCache.txt文件。似乎還有其他地方存儲的值(可能是CMakeFiles目錄),阻止CMake正確更新編譯器。它現在適用於這兩種方法。 – Chris