Skip to content

Commit

Permalink
used the CheckCXXCompilerFlag module of Cmake to check the compiler w…
Browse files Browse the repository at this point in the history
…hether or not supporting c++11. (iovisor#1116)
  • Loading branch information
monadbobo authored and goldshtn committed Apr 17, 2017
1 parent 5c08041 commit 2d82c8e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enable_testing()
include(cmake/GetGitRevisionDescription.cmake)
include(cmake/version.cmake)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Expand Down Expand Up @@ -64,7 +65,14 @@ if (USINGISYSTEM AND GCC_VERSION VERSION_LESS 6.0)
endforeach()
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall ${CXX_ISYSTEM_DIRS}")
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(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ${CXX_ISYSTEM_DIRS}")
endif()

add_subdirectory(examples)
Expand Down

0 comments on commit 2d82c8e

Please sign in to comment.