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

Robert Maynard robert.maynard at kitware.com
Tue Dec 16 15:24:17 EST 2014


If your CMake minimum required version is 3.0 you need to check for
AppleClang not Clang (
http://www.cmake.org/cmake/help/v3.0/policy/CMP0025.html#policy:CMP0025
).

On Tue, Dec 16, 2014 at 3:19 PM, Robert Ramey <ramey at rrsd.com> wrote:
> 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.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list