[CMake] Generating an Xcode project for C++11

Robert Ramey ramey at rrsd.com
Tue Dec 16 15:19:27 EST 2014


My CMakeLists.txt contains in part:
<blockquote>
#
# Compiler settings
#

message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" )

if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
  add_definitions( -ftemplate-depth=300 )
  # we use gcc to test for C++03 compatibility
  add_definitions( std=c++03 )
  message(STATUS "compiler is g++ c++03")
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
  add_definitions( /wd4996 )
  message(STATUS "compiler is MSVC")
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=300")
  #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" )
  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" )
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++
-dead_strip")
endif()

#
# IDE settings
#

if( CMAKE_HOST_APPLE )
  # note: it seems that bjam builds both address models in any case
  # so we can defer this decision to the IDE just as we do for debug/release
  # so we'll not use this now
  # set(Boost_ADDRESS_MODEL 64 CACHE INTEGER "32/64 bits")
  set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link to Boost static libraries")
  set(Boost_USE_MULTITHREADED ON)
else()
  set(Boost_ADDRESS_MODEL 64 CACHE INTEGER "32/64 bits")
  set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link to Boost static libraries")
  set(Boost_USE_MULTITHREADED ON)
endif()
</blockquote>

but the Xcode project generated specifies under 
Apple LLVM 6.0 Language - C++
  C++ Language Dialect
     Compiler Default

rather than what I want which is:

Apple LLVM 6.0 Language - C++
  C++ Language Dialect
     C++11 [-std=c++11]

What do I have to change to get the desired result?

RObert Ramey





--
View this message in context: http://cmake.3232098.n2.nabble.com/Generating-an-Xcode-project-for-C-11-tp7589301.html
Sent from the CMake mailing list archive at Nabble.com.


More information about the CMake mailing list