+include(CheckCSourceCompiles)
+include(CheckCXXCompilerFlag)
+include(CheckCXXSourceCompiles)
+include(CMakePushCheckState)
+include(memaccess)
+
+find_package(PkgConfig)
+
+if(CMAKE_VERSION VERSION_EQUAL "3.8.0" OR CMAKE_VERSION VERSION_GREATER "3.8.0")
+ check_cxx_compiler_flag("-std=c++17" HAVE_STD_CXX_17)
+ check_cxx_compiler_flag("-std=c++14" HAVE_STD_CXX_14)
+ check_cxx_compiler_flag("-std=c++11" HAVE_STD_CXX_11)
+ if(HAVE_STD_CXX_17)
+ message(STATUS "Using C++17 for the application build")
+ set(CMAKE_CXX_STANDARD 17)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++17")
+ elseif(HAVE_STD_CXX_14)
+ message(STATUS "Using C++14 for the application build")
+ set(CMAKE_CXX_STANDARD 14)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++14")
+ elseif(HAVE_STD_CXX_11)
+ message(STATUS "Using C++11 for the application build")
+ set(CMAKE_CXX_STANDARD 11)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++11")
+ else()
+ message(FATAL_ERROR "Need modern C++, at least language standard 11")
+ endif()
+else()
+ check_cxx_compiler_flag("-std=c++14" HAVE_STD_CXX_14)
+ check_cxx_compiler_flag("-std=c++11" HAVE_STD_CXX_11)
+ if(HAVE_STD_CXX_14)
+ message(STATUS "Using C++14 for the application build")
+ set(CMAKE_CXX_STANDARD 14)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++14")
+ elseif(HAVE_STD_CXX_11)
+ message(STATUS "Using C++11 for the application build")
+ set(CMAKE_CXX_STANDARD 11)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++11")
+ else()
+ message(FATAL_ERROR "Need modern C++, at least language standard 11")
+ endif()
+endif()
+