find_package(PkgConfig)
-check_cxx_compiler_flag("-std=c++17" PV_HAVE_C++17)
+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()
list(APPEND PKGDEPS glib-2.0>=2.28.0)
# Helper for checking for atomics
function(check_working_cxx_atomics varname additional_lib)
cmake_push_check_state()
- # The OSX 12 (Monteray) stdlib requires C++17 to compile.
- if(APPLE AND PV_HAVE_C++17)
- message(STATUS "Using C++17 for OSX build")
- set(CMAKE_REQUIRED_FLAGS "-std=c++17")
- else()
- set(CMAKE_REQUIRED_FLAGS "-std=c++11")
- endif()
+ set(CMAKE_REQUIRED_FLAGS "${REQUIRED_STD_CXX_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}")
set(CMAKE_REQUIRED_QUIET 1)
CHECK_CXX_SOURCE_COMPILES("
add_definitions(-DQT_NO_KEYWORDS)
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(-Wall -Wextra)
-
-# The OSX 12 Monteray stdlib requires C++17 to compile.
-if(APPLE AND PV_HAVE_C++17)
- add_definitions(-std=c++17)
-else()
- add_definitions(-std=c++11)
-endif()
+add_definitions(${REQUIRED_STD_CXX_FLAGS})
add_definitions(-DBOOST_MATH_DISABLE_FLOAT128=1)
if(WIN32)