From: Pasukhin Dmitry Date: Fri, 16 May 2025 09:30:25 +0000 (+0100) Subject: Configuration - Update minimum version of C++ to 17 #537 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=3e80fad1779e4fab620d1ab1982bfd7722b6c92b;p=occt.git Configuration - Update minimum version of C++ to 17 #537 Update C++ standard to C++17 in build configuration and documentation --- diff --git a/.github/actions/build-occt/action.yml b/.github/actions/build-occt/action.yml index 2f30680886..f081d17f3c 100644 --- a/.github/actions/build-occt/action.yml +++ b/.github/actions/build-occt/action.yml @@ -99,7 +99,7 @@ runs: -D USE_RAPIDJSON=ON ` -D USE_OPENGL=ON ` -D BUILD_GTEST=ON ` - -D BUILD_CPP_STANDARD=C++14 ` + -D BUILD_CPP_STANDARD=C++17 ` -D INSTALL_GTEST=ON ${{ inputs.additional-cmake-flags }} .. shell: pwsh @@ -130,7 +130,7 @@ runs: -D USE_RAPIDJSON=ON ` -D USE_OPENGL=ON ` -D BUILD_GTEST=ON ` - -D BUILD_CPP_STANDARD=C++14 ` + -D BUILD_CPP_STANDARD=C++17 ` -D INSTALL_GTEST=ON ` -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wno-unknown-warning-option" ` -D CMAKE_C_FLAGS="-Werror -Wall -Wextra -Wno-unknown-warning-option" ${{ inputs.additional-cmake-flags }} .. @@ -155,7 +155,7 @@ runs: -D USE_OPENGL=ON \ -D USE_FREEIMAGE=ON \ -D BUILD_GTEST=ON \ - -D BUILD_CPP_STANDARD=C++14 \ + -D BUILD_CPP_STANDARD=C++17 \ -D INSTALL_GTEST=ON \ -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ -D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ${{ inputs.additional-cmake-flags }} .. @@ -187,7 +187,7 @@ runs: -D USE_RAPIDJSON=ON \ -D USE_OPENGL=ON \ -D BUILD_GTEST=ON \ - -D BUILD_CPP_STANDARD=C++14 \ + -D BUILD_CPP_STANDARD=C++17 \ -D INSTALL_GTEST=ON \ ${{ inputs.compiler == 'clang' && '-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" -D CMAKE_C_FLAGS="-Werror -Wall -Wextra"' || '' }} ${{ inputs.additional-cmake-flags }} .. shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 5def27cf3e..5235335235 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,27 +65,21 @@ set (CMAKE_SUPPRESS_REGENERATION TRUE) set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE) # set using C++ standard -set (BUILD_CPP_STANDARD "C++11" CACHE STRING "Select using c++ standard.") -set_property(CACHE BUILD_CPP_STANDARD PROPERTY STRINGS "C++11" "C++14" "C++17" "C++20" "C++23") +set (BUILD_CPP_STANDARD "C++17" CACHE STRING "Select using c++ standard.") +set_property(CACHE BUILD_CPP_STANDARD PROPERTY STRINGS "C++17" "C++20" "C++23 C++26") # Set desired C++ standard -if ("${BUILD_CPP_STANDARD}" STREQUAL "C++11") - set (CMAKE_CXX_STANDARD 11) -elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++14") - set (CMAKE_CXX_STANDARD 14) -elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++17") +if ("${BUILD_CPP_STANDARD}" STREQUAL "C++17") set (CMAKE_CXX_STANDARD 17) elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++20") set (CMAKE_CXX_STANDARD 20) elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++23") set (CMAKE_CXX_STANDARD 23) -else () - message (FATAL_ERROR, "misprint in c++ standard name") -endif() - -if (DEFINED BUILD_GTEST AND BUILD_GTEST AND CMAKE_CXX_STANDARD LESS 14) - set (CMAKE_CXX_STANDARD 14) - message (STATUS "Info: C++14 standard is required for GTest. Set to C++14.") +elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++26") + set (CMAKE_CXX_STANDARD 26) +else() + message (WARNING "C++ standard is not set or invalid. Set to C++17.") + set (CMAKE_CXX_STANDARD 17) endif() set (CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/adm/cmake/occt_macros.cmake b/adm/cmake/occt_macros.cmake index 21114a5567..59e5c2eb37 100644 --- a/adm/cmake/occt_macros.cmake +++ b/adm/cmake/occt_macros.cmake @@ -72,24 +72,9 @@ endmacro() macro (OCCT_MAKE_COMPILER_SHORT_NAME) if (MSVC) if (MSVC_VERSION LESS 1914) - message (AUTHOR_WARNING "Microsoft Visual C++ 19.14 (VS 2017 15.7) or newer is required for C++17 support") + message (FATAL_ERROR "Microsoft Visual C++ 19.14 (VS 2017 15.7) or newer is required for C++17 support") endif() - - if ((MSVC_VERSION EQUAL 1300) OR (MSVC_VERSION EQUAL 1310)) - set (COMPILER vc7) - elseif (MSVC_VERSION EQUAL 1400) - set (COMPILER vc8) - elseif (MSVC_VERSION EQUAL 1500) - set (COMPILER vc9) - elseif (MSVC_VERSION EQUAL 1600) - set (COMPILER vc10) - elseif (MSVC_VERSION EQUAL 1700) - set (COMPILER vc11) - elseif (MSVC_VERSION EQUAL 1800) - set (COMPILER vc12) - elseif (MSVC_VERSION EQUAL 1900) - set (COMPILER vc14) - elseif ((MSVC_VERSION GREATER 1900) AND (MSVC_VERSION LESS 2000)) + if ((MSVC_VERSION GREATER 1900) AND (MSVC_VERSION LESS 2000)) # Since Visual Studio 15 (2017), its version diverged from version of # compiler which is 14.1; as that compiler uses the same run-time as 14.0, # we keep its id as "vc14" to be compatible @@ -99,28 +84,28 @@ macro (OCCT_MAKE_COMPILER_SHORT_NAME) endif() elseif (DEFINED CMAKE_COMPILER_IS_GNUCC) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) - message (AUTHOR_WARNING "GCC version 8.0 or newer is required for C++17 support") + message (FATAL_ERROR "GCC version 8.0 or newer is required for C++17 support") endif() set (COMPILER gcc) elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) - message (AUTHOR_WARNING "GCC version 8.0 or newer is required for C++17 support") + message (FATAL_ERROR "GCC version 8.0 or newer is required for C++17 support") endif() set (COMPILER gxx) elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]") if(APPLE) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.0) - message (AUTHOR_WARNING "Apple Clang version 11.0.0 or newer is required for C++17 support") + message (FATAL_ERROR "Apple Clang version 11.0.0 or newer is required for C++17 support") endif() else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) - message (AUTHOR_WARNING "Clang version 7.0 or newer is required for C++17 support") + message (FATAL_ERROR "Clang version 7.0 or newer is required for C++17 support") endif() endif() set (COMPILER clang) elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Ii][Nn][Tt][Ee][Ll]") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.1.1) - message (AUTHOR_WARNING "Intel C++ Compiler version 17.1.1 or newer is required for C++17 support") + message (FATAL_ERROR "Intel C++ Compiler version 17.1.1 or newer is required for C++17 support") endif() set (COMPILER icc) else() diff --git a/dox/build/build_occt/building_occt.md b/dox/build/build_occt/building_occt.md index 8288b9101f..500359ef41 100644 --- a/dox/build/build_occt/building_occt.md +++ b/dox/build/build_occt/building_occt.md @@ -118,7 +118,7 @@ The following table gives the full list of environment variables used at the con | BUILD_INCLUDE_SYMLINK | Boolean | Use symbolic links instead of copies for header files in build directory | | BUILD_MODULE_| Boolean | Indicates whether the corresponding OCCT module should be built | | BUILD_LIBRARY_TYPE | String | Specifies library type ("Shared" or "Static") | -| BUILD_CPP_STANDARD | String | Select C++ standard (C++11, C++14, C++17, C++20, C++23) | +| BUILD_CPP_STANDARD | String | Select C++ standard (C++17, C++20, C++23, C++26) | | 3RDPARTY_DIR | Path | Defines the root directory where all required 3rd party products will be searched. Once you define this path it is very convenient to click "Configure" button in order to let CMake automatically detect all necessary products| | 3RDPARTY_FREETYPE_* | Path | Path to FreeType binaries | | 3RDPARTY_TCL_* 3RDPARTY_TK_* | Path | Path to Tcl/Tk binaries |