我想看看我的C ++项目是否编译的是较旧版本的GCC。 为此,我已经安装了旧版本,并希望CMake的用它来编译我的项目。
CMake的FAQ 上改变编译器告诉我,这是做的正确方法:
CC=gcc-4.4 CXX=g++-4.4 cmake -G "Unix Makefiles" ..
所以这是我打字和CMake的似乎运行正常:
chris@chris-machine:~/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的再次它将创建一个无限循环:
chris@chris-machine:~/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的不使用我指定的编译器,我怎么能解决这个问题?