cmake抱怨缺乏对C&x2B的支持+;尽管安装了最新版本的clang,编译器的0x

cmake抱怨缺乏对C&x2B的支持+;尽管安装了最新版本的clang,编译器的0x,cmake,clang,ubuntu-14.04,pdf2htmlex,Cmake,Clang,Ubuntu 14.04,Pdf2htmlex,我正在尝试使用cmake来构建 这是错误消息: CMake Error at CMakeLists.txt:108 (message): Error: your compiler does not support C++0x, please update it 下面是clang编译器的版本号 $ which clang /usr/bin/clang $ which c++ /usr/bin/c++ $ clang --version Ubuntu clang version 3.5-1ub

我正在尝试使用cmake来构建

这是错误消息:

CMake Error at CMakeLists.txt:108 (message):
  Error: your compiler does not support C++0x, please update it
下面是clang编译器的版本号

$ which clang
/usr/bin/clang
$ which c++
/usr/bin/c++
$ clang --version
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ c++ --version
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix
快速测试后,我意识到
clang
不支持
-std=c++0x
。我删除了clang并安装了g++。以下是相关的版本信息:

$ which g++
/usr/bin/g++
$ which c++
/usr/bin/c++
$ g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ $ c++ --version
c++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我运行了一个非常简单的测试,似乎g++可以接受
c++0x
参数

g++ -std=c++0x /tmp/c/t.cpp
我正在Ubuntu 14.04.1 LTS上运行cmake

CMake

其版本为
cmake版本2.8.12.2

以下是
CMakeLists.txt

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("${CMAKE_CXX_FLAGS}" CXX0X_SUPPORT)
if(NOT CXX0X_SUPPORT)
    message(FATAL_ERROR "Error: your compiler does not support C++0x, please update it.")
endif()

我是cmake的新手,因此不知道如何确定cmake对
check\u cxx\u compiler\u flag
执行的检查结果是“cmake”缓存问题

当我第一次运行cmake时,它选择了不支持
-std=c++0x
选项的
clang++
。随后运行的cmake会继续报告相同的缓存结果,即使已删除clang并安装了correct
g++

以下是解决方案:

再次运行cmake之前,请删除文件夹
CMakeFiles
和文件
CMakeCache.txt

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("${CMAKE_CXX_FLAGS}" CXX0X_SUPPORT)
if(NOT CXX0X_SUPPORT)
    message(FATAL_ERROR "Error: your compiler does not support C++0x, please update it.")
endif()