]> OCCT Git - occt.git/commitdiff
Configuration - Update minimum version of C++ to 17 #537
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Fri, 16 May 2025 09:30:25 +0000 (10:30 +0100)
committerGitHub <noreply@github.com>
Fri, 16 May 2025 09:30:25 +0000 (10:30 +0100)
Update C++ standard to C++17 in build configuration and documentation

.github/actions/build-occt/action.yml
CMakeLists.txt
adm/cmake/occt_macros.cmake
dox/build/build_occt/building_occt.md

index 2f30680886059cb064d6e0b735d121ee7f746f3e..f081d17f3c2d2ee668c92418795535cb50965eb0 100644 (file)
@@ -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
index 5def27cf3ed9e39621727e6889c3fd3af49bc869..52353352356d92eab48d60872f1758a9d4070781 100644 (file)
@@ -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)
index 21114a55670484051b30f978ed8c2b1f54aa2204..59e5c2eb37061319e99cb626502db7a4fec4d19c 100644 (file)
@@ -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()
index 8288b9101fa1827f684ca70105eeaa7b29d9f048..500359ef4100d7fb2d79cd29cece4162016ac2f2 100644 (file)
@@ -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_<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 |