Search code examples
cmakeclangubuntu-14.04pdf2htmlex

cmake complaints about lack of support of C++0x of the compiler despite the latest version of clang is installed


I am trying to use cmake to build pdf2htmlEX

This is the error message:

CMake Error at CMakeLists.txt:108 (message):
  Error: your compiler does not support C++0x, please update it

Here is the version number of the clang compiler

$ 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

After a quick test I realised clang does not support -std=c++0x. I removed clang and installed g++. Here are the relevant version information:

$ 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.

I have run a very simple test and it seems g++ can accept the c++0x parameter

g++ -std=c++0x /tmp/c/t.cpp

I am running cmake on Ubuntu 14.04.1 LTS

CMake

Its version is cmake version 2.8.12.2

Here is the relevant code in the 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()

I am new to cmake so do not know how to determine what check is being carried for check_cxx_compiler_flag by cmake


Solution

  • It turns out to be a 'cmake' caching problem

    When I ran cmake for the first time, it picked up clang++ which does not support the -std=c++0x option. Subsequent run of cmake keeps reporting the same cached result, even though clang has been removed and correct g++ is installed.

    Here is the solution:

    Before running cmake again, remove the folder CMakeFiles and the file CMakeCache.txt