]> SALOME platform Git repositories - tools/configuration.git/commitdiff
Salome HOME
Add option to choose C++ standard; default value is set to 11 (requries CMake minimal...
authorvsr <vsr@opencascade.com>
Mon, 14 Sep 2020 08:33:05 +0000 (11:33 +0300)
committervsr <vsr@opencascade.com>
Mon, 14 Sep 2020 08:33:05 +0000 (11:33 +0300)
cmake/SalomeMacros.cmake
cmake/SalomeSetupPlatform.cmake

index 33078a936556b0642ecf2a84f7b8f3a3d9ddb42b..d24b042896c47555fff784557065f7784eb0ffda 100644 (file)
@@ -27,6 +27,7 @@ IF(WIN32)
   CMAKE_POLICY(SET CMP0020 OLD) # Disable automatic linking to qtmain.lib
 ENDIF(WIN32)
 CMAKE_POLICY(SET CMP0053 NEW)   # For correct Qt 5 detection procedure
+CMAKE_POLICY(SET CMP0057 NEW)   # For IF(IN_LIST) operator
 IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
   CMAKE_POLICY(SET CMP0074 NEW) # Use ROOT variables when detecting packages
 ENDIF()
index abfb734f4fe0fbcefd28b264d4e1f0dc81e441d1..a5f713a0110ee1a66e4ac265e0d166c3f92c1f10 100644 (file)
@@ -106,7 +106,16 @@ IF(COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names")
 ENDIF()
 
-SET(CMAKE_CXX_STANDARD 17)
+# C++ standard to use; NOTE: extensions are not allowed!
+SET(SALOME_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
+SET(_supported_standards 11 14 17 20)
+IF(NOT ${SALOME_CXX_STANDARD} IN_LIST _supported_standards)
+  MESSAGE(FATAL_ERROR "Unsupported C++ standard: ${SALOME_CXX_STANDARD}; allowed values: ${_supported_standards}")
+ENDIF()
+UNSET(_supported_standards)
+MESSAGE(STATUS "Setting C++ standard to ${SALOME_CXX_STANDARD}")
+SET(CMAKE_CXX_STANDARD ${SALOME_CXX_STANDARD})
+SET(CMAKE_CXX_EXTENSIONS OFF)
 SET(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 # Fight warnings