diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ac2873..aceea07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,26 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_AUTOMOC ON) +# C++ 11 support +if (CMAKE_VERSION VERSION_LESS "3.1") + 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() + CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + # -std=c++0x is deprecated but some tools e.g. qmake or older gcc are still using it + if(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + else() + message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} does not support c++11/c++0x") + endif() + endif() +else() + set(CMAKE_CXX_STANDARD 11) +endif() + + find_package(Qt5Widgets REQUIRED) find_package(Qt5DBus REQUIRED) find_package(Qt5PrintSupport REQUIRED QUIET)