-# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
#
-# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
SET(${PROJECT_NAME_UC}_MAJOR_VERSION 2)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 1)
-SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 6)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
LIBBATCH_FIND_ALL_LOCAL_COMMANDS()
ENDIF()
+INCLUDE(CheckCXXCompilerFlag)
+
+# Option: C++ standard to use
+# Note: CMake by default enables C++ extensions; they can be disabled by additionally
+# specifying -DCMAKE_CXX_EXTENSIONS=OFF
+SET(LIBBATCH_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
+SET(_supported_standards 11 14 17 20)
+SET(_standard_ok FALSE)
+FOREACH(_standard ${_supported_standards})
+ IF(LIBBATCH_CXX_STANDARD STREQUAL _standard)
+ SET(_standard_ok TRUE)
+ BREAK()
+ ENDIF()
+ENDFOREACH()
+IF(NOT _standard_ok)
+ MESSAGE(FATAL_ERROR "Unsupported C++ standard: ${LIBBATCH_CXX_STANDARD}; allowed values: ${_supported_standards}")
+ENDIF()
+UNSET(_supported_standards)
+UNSET(_standard)
+UNSET(_standard_ok)
+MESSAGE(STATUS "Setting C++ standard to ${LIBBATCH_CXX_STANDARD}")
+SET(CMAKE_CXX_STANDARD ${LIBBATCH_CXX_STANDARD})
+SET(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+IF(NOT (WIN32 OR APPLE))
+ SET(LIBBATCH_DEBUG_WARNINGS FALSE CACHE BOOL "Print more compiler warnings")
+ SET(LIBBATCH_TREAT_WARNINGS_AS_ERRORS FALSE CACHE BOOL "Treat compiler warnings as errors")
+ IF(LIBBATCH_DEBUG_WARNINGS)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
+ ENDIF()
+ IF(LIBBATCH_TREAT_WARNINGS_AS_ERRORS)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+ ENDIF()
+ENDIF()
+
+# Compiler flag to disable treating alternative C++ tokens (compatibility with MSVS)
+CHECK_CXX_COMPILER_FLAG("-fno-operator-names" COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
+IF(COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names")
+ENDIF()
+
# Prerequisites detection:
# ========================
FIND_PACKAGE(LibbatchPThread REQUIRED)