Skip to content

Commit

Permalink
Enable C++11 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
GyrosGeier authored and Wayne Stambaugh committed Mar 21, 2016
1 parent a4ba01f commit 2d4845d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions CMakeLists.txt
Expand Up @@ -82,6 +82,11 @@ set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
set( CMAKE_POSITION_INDEPENDENT_CODE ON )


# Global setting: Use C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# CMP0063: CMake < 3.3 does not handle hidden visibility for static libraries,
# and 3.3 is backwards compatible when the minimum version is smaller than 3.3.
if( POLICY CMP0063 )
Expand Down Expand Up @@ -129,6 +134,24 @@ include( PerformFeatureChecks )
perform_feature_checks()


# Workaround: CMake < 3.1 does not support CMAKE_CXX_STANDARD
if( NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.1 )
message( FATAL_ERROR "Remove compatibility code" )
endif()

if( CMAKE_VERSION VERSION_LESS 3.1 AND ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) )
include(CheckCXXCompilerFlag)

CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)

if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
endif()


#================================================
# Set flags for GCC, or treat llvm as GCC
#================================================
Expand Down

0 comments on commit 2d4845d

Please sign in to comment.