X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;h=5f3156e467a1c4cd38e1dfd653599796353a9a0b;hb=b4e59846fd2eaf893548f182645e7162da4ad731;hp=3a0c7c6818d6a68352ce472ed5ef45d6576c803b;hpb=3479e9f2b695b8577949fbb6ab38d4bdfbd419da;p=tools%2Flibbatch.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a0c7c6..5f3156e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,23 @@ -# 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) @@ -29,8 +29,8 @@ PROJECT(LibBatch C CXX) STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) SET(${PROJECT_NAME_UC}_MAJOR_VERSION 2) -SET(${PROJECT_NAME_UC}_MINOR_VERSION 0) -SET(${PROJECT_NAME_UC}_PATCH_VERSION 0) +SET(${PROJECT_NAME_UC}_MINOR_VERSION 4) +SET(${PROJECT_NAME_UC}_PATCH_VERSION 4) SET(${PROJECT_NAME_UC}_VERSION ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) @@ -40,20 +40,70 @@ INCLUDE(libbatchMacros) # User options # ============ -SET(INSTALL_CMAKE_CONFIG_DIR share/cmake) +IF(WIN32 AND NOT CYGWIN) + # This is really stupid: in the FIND_PACKAGE() command, the default paths + # are not the same under Win and Nix (see CMake doc). This means we have to specify + # different installation directories for LibBatchConfig.cmake: + SET(INSTALL_CMAKE_CONFIG_DIR cmake) +ELSE() + SET(INSTALL_CMAKE_CONFIG_DIR share/cmake/libbatch) +ENDIF() SET(INSTALL_INCLUDE_DIR include) SET(LIBBATCH_LOCAL_SUBMISSION TRUE CACHE BOOL "Build classes for local submission") SET(LIBBATCH_PYTHON_WRAPPING TRUE CACHE BOOL "Generate Python wrapping") -SET(LIBBATCH_TESTS FALSE CACHE BOOL "Enable testing") +SET(LIBBATCH_BUILD_TESTS FALSE CACHE BOOL "Enable testing") -IF(LIBBATCH_TESTS) +IF(LIBBATCH_BUILD_TESTS) ENABLE_TESTING() ENDIF() IF(LIBBATCH_LOCAL_SUBMISSION) 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) @@ -62,7 +112,7 @@ IF (LIBBATCH_PYTHON_WRAPPING) FIND_PACKAGE(LibbatchPython REQUIRED) FIND_PACKAGE(LibbatchSWIG REQUIRED) - MESSAGE("TODO TODO check Python path win32") + SET(PYTHON_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") SET(LIBBATCH_PYTHONPATH lib/python${PYTHON_VERSION}/site-packages) ENDIF()