[CMake] set(CMAKE_CXX_STANDARD 11) on macos - "...CMake does not know the compile flags to use to enable it."

Laurent Demailly ldemailly at fb.com
Fri Jan 16 19:40:01 EST 2015


Answering my own question : this is fixed on trunk

http://www.cmake.org/Bug/view.php?id=15355

Laurent


From: Laurent Demailly <ldemailly at fb.com<mailto:ldemailly at fb.com>>
Date: Wednesday, January 14, 2015 at 8:33 PM
To: "cmake at cmake.org<mailto:cmake at cmake.org>" <cmake at cmake.org<mailto:cmake at cmake.org>>
Subject: [CMake] set(CMAKE_CXX_STANDARD 11) on macos - "...CMake does not know the compile flags to use to enable it."

Hi all,

I have a very simple CMakeLists.txt – am using cmake 3.1 to be able to easily request C++ 11 – it works fine on ubuntu but not on MacOS with Xcode 6 and command line tools installed:

$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.1)

project("Test1" C CXX)

# We need C++ 11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)

file(WRITE test1.cpp "int main(int argc, char** argv) {auto x=argc; return x;}")

add_executable(test1 test1.cpp)

$ cmake31 .
-- The C compiler identification is AppleClang 6.0.0.6000056
-- The CXX compiler identification is AppleClang 6.0.0.6000056
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
CMake Error in CMakeLists.txt:
  Target "test1" requires the language dialect "CXX11" (with compiler
  extensions), but CMake does not know the compile flags to use to enable it.


This is with
CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
CXXFLAGS="-std=c++11"
But same without that


Any idea why Cmake complains and how to not make it complain ?


Help/pointer greatly appreciated

Thanks
Laurent


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150117/1d9bd9e5/attachment.html>


More information about the CMake mailing list