Skip to content
This repository has been archived by the owner on May 13, 2019. It is now read-only.

Commit

Permalink
cmake: simplify the way we choose the C++ standard to use
Browse files Browse the repository at this point in the history
This will make it easier to try out C++14 features
  • Loading branch information
arximboldi committed Aug 18, 2015
1 parent b613938 commit ca62bab
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions CMakeLists.txt
Expand Up @@ -7,23 +7,15 @@ set(Atria_VERSION_MAJOR 0)
set(Atria_VERSION_MINOR 0)

# Enable C++11
include(CheckCXXCompilerFlag)
if(WIN32)
# Check if we are using Visual Studio 2013 or later
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12)
message(FATAL_ERROR
"You are using an unsupported Windows compiler! "
"(Visual C++ 2013 or later required)")
endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED on)

if(CMAKE_CXX_STANDARD STREQUAL 14)
add_definitions(-DABL_CXX14=1)
else()
set(cxx11_options -std=c++11)
CHECK_CXX_COMPILER_FLAG(${cxx11_options} COMPILER_SUPPORTS_CXX11)

if(NOT COMPILER_SUPPORTS_CXX11)
message(FATAL_ERROR
"The compiler ${CMAKE_CXX_COMPILER} has insufficient C++11 support. "
"Please use a different C++ compiler.")
endif()
add_definitions(-DABL_CXX14=0)
endif()

# Build debug by default
Expand Down Expand Up @@ -92,7 +84,8 @@ target_include_directories(atria PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third-party/eggs-variant/include>
${Boost_INCLUDE_DIRS})
target_compile_options(atria
PUBLIC ${cxx11_options} ${warning_options})
PUBLIC
${warning_options})
target_link_libraries(atria
${Boost_LIBRARIES})

Expand Down

0 comments on commit ca62bab

Please sign in to comment.