-# Copyright (C) 2015 CEA/DEN, EDF R&D
+# Copyright (C) 2015-2021 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms 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
+#
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2 FATAL_ERROR)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR)
#INCLUDE(CMakeDependentOption)
PROJECT(MEDCoupling C CXX)
-# Ensure a proper linker behavior:
-CMAKE_POLICY(SET CMP0003 NEW)
+
+IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.3)
+ cmake_policy(SET CMP0057 NEW)
+ IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.13)
+ cmake_policy(SET CMP0078 OLD)
+ ENDIF()
+ IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.14)
+ cmake_policy(SET CMP0086 OLD)
+ ENDIF()
+ENDIF()
+
# Versioning
# ===========
# Project name, upper case
STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
-SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
+SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9)
SET(${PROJECT_NAME_UC}_MINOR_VERSION 7)
SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-# Our own set of macros:
-LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_files")
-INCLUDE(SalomeMacros)
+# Common CMake macros
+SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake files")
+IF(EXISTS ${CONFIGURATION_ROOT_DIR})
+ LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
+ INCLUDE(SalomeMacros NO_POLICY_SCOPE)
+ELSE()
+ MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
+ENDIF()
# Platform setup
# ==============
INCLUDE(SalomeSetupPlatform)
+# [ABN]: use the below for aggressive code quality check:
+#if( EXISTS "aaaa")
+# add_definitions(-Weverything)
+# add_definitions(-Wno-inconsistent-missing-override)
+# add_definitions(-Wno-c++98-compat -Wno-c++98-compat-pedantic)
+# add_definitions(-Wno-sign-conversion)
+# add_definitions(-Wno-switch-enum)
+#
+# add_definitions(-Wno-documentation-unknown-command) # \image in Doxygen
+# add_definitions(-Wno-gnu-statement-expression) # assert(...)
+#
+# add_definitions(-Wno-reserved-id-macro -Wno-padded -Wno-weak-vtables -Wdouble-promotion -Wno-comma -Wno-unused-parameter)
+# add_definitions(-Wno-unreachable-code-break -Wno-old-style-cast -Wno-deprecated -Wno-double-promotion)
+# add_definitions(-Wno-exit-time-destructors -Wno-global-constructors -Wno-missing-prototypes)
+# add_definitions(-Wno-covered-switch-default -Wno-weak-template-vtables -Wno-undefined-func-template -Wno-used-but-marked-unused)
+# add_definitions(-Wno-unreachable-code-return -Wno-missing-noreturn -Wno-unused-member-function -Wno-header-hygiene)
+# add_definitions(-Wno-ignored-qualifiers) # because of MED-file
+# add_definitions(-Wno-unused-function -Wno-unused-macros)
+# add_definitions(-Wno-missing-field-initializers)
+# add_definitions(-Wno-shadow) # SWIG generates a lot of those ...
+#
+# add_definitions(-Wno-float-equal) # OUCH
+#endif()
+
#
# User options
# ============
INCLUDE(CMakeDependentOption)
-OPTION(MEDCOUPLING_MICROMED "Build MED without MED file dependancy." OFF)
+OPTION(MEDCOUPLING_MICROMED "Build MED without MED file dependency." OFF)
OPTION(MEDCOUPLING_ENABLE_PYTHON "Build PYTHON bindings." ON)
OPTION(MEDCOUPLING_ENABLE_PARTITIONER "Build MEDPartitioner." ON)
OPTION(MEDCOUPLING_ENABLE_RENUMBER "Build Renumber." ON)
OPTION(MEDCOUPLING_USE_MPI "(Use MPI containers) - For MED this triggers the build of ParaMEDMEM." OFF)
OPTION(MEDCOUPLING_BUILD_TESTS "Build MED tests." ON)
OPTION(MEDCOUPLING_BUILD_DOC "Build MED doc." ON)
-CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_METIS "Enable metis graph library in MEDPartitioner." ON "MEDCOUPLING_ENABLE_PARTITIONER" OFF)
-CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_SCOTCH "Enable scotch graph library in MEDPartitioner." ON "MEDCOUPLING_ENABLE_PARTITIONER;NOT MEDCOUPLING_USE_MPI" OFF)
-CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_PARMETIS "Enable parmetis graph library in MEDPartitioner." ON "MEDCOUPLING_ENABLE_PARTITIONER;MEDCOUPLING_USE_MPI" OFF)
+OPTION(MEDCOUPLING_BUILD_STATIC "Build MEDCoupling library in static mode." OFF)
+OPTION(MEDCOUPLING_USE_64BIT_IDS "Size of IDs to refer cells and nodes. 32 bits when OFF (default), 64 bits when ON." ON)
+
+IF(${MEDCOUPLING_USE_MPI})
+ SET(USE_METIS_NOT_PARMETIS OFF)
+ELSE()
+ SET(USE_METIS_NOT_PARMETIS ON)
+ENDIF()
+CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_METIS "Enable metis graph library in MEDPartitioner." ${USE_METIS_NOT_PARMETIS}
+ "MEDCOUPLING_ENABLE_PARTITIONER" OFF)
+CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_SCOTCH "Enable scotch graph library in MEDPartitioner." ON
+ "MEDCOUPLING_ENABLE_PARTITIONER" OFF)
+CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_PARMETIS "Enable parmetis graph library in MEDPartitioner." ${MEDCOUPLING_USE_MPI}
+ "MEDCOUPLING_ENABLE_PARTITIONER;MEDCOUPLING_USE_MPI" OFF)
+CMAKE_DEPENDENT_OPTION(MEDCOUPLING_PARTITIONER_PTSCOTCH "Enable ptscotch graph library in MEDPartitioner." ${MEDCOUPLING_USE_MPI}
+ "MEDCOUPLING_ENABLE_PARTITIONER;MEDCOUPLING_USE_MPI" OFF)
+SET(XDR_DEFAULT_OPTION ON)
IF(WIN32)
- CMAKE_DEPENDENT_OPTION(MEDCOUPLING_MEDLOADER_USE_XDR "Enable use of XDR for SauvReader." ON "NOT MEDCOUPLING_MICROMED" OFF)
-ENDIF(WIN32)
+ SET(XDR_DEFAULT_OPTION OFF)
+ENDIF()
+CMAKE_DEPENDENT_OPTION(MEDCOUPLING_MEDLOADER_USE_XDR "Enable use of XDR for SauvReader." ${XDR_DEFAULT_OPTION} "NOT MEDCOUPLING_MICROMED" OFF)
+CMAKE_DEPENDENT_OPTION(MEDCOUPLING_BUILD_FRENCH_DOC "Generate MEDCOUPLING French documentation" OFF
+ "MEDCOUPLING_BUILD_DOC" OFF)
+
+IF(MEDCOUPLING_BUILD_STATIC)
+ SET(BUILD_SHARED_LIBS 0)
+ SET(CMAKE_POSITION_INDEPENDENT_CODE 1) # -fPIC option
+ELSE()
+ SET(BUILD_SHARED_LIBS 1)
+ENDIF()
+
+IF(${MEDCOUPLING_PARTITIONER_PARMETIS} AND ${MEDCOUPLING_PARTITIONER_METIS})
+ MESSAGE(FATAL_ERROR "ParMetis and Metis are mutually exclusive! Make a choice (options MEDCOUPLING_PARTITIONER_METIS and MEDCOUPLING_PARTITIONER_PARMETIS).")
+ENDIF()
+
+IF(${MEDCOUPLING_PARTITIONER_PTSCOTCH} AND ${MEDCOUPLING_PARTITIONER_SCOTCH})
+ MESSAGE(FATAL_ERROR "PTScotch and Scotch are mutually exclusive! Make a choice (options MEDCOUPLING_PARTITIONER_SCOTCH and MEDCOUPLING_PARTITIONER_PTSCOTCH).")
+ENDIF()
#
# Set list of prerequisites
FIND_PACKAGE(SalomeHDF5 REQUIRED)
FIND_PACKAGE(SalomeMEDFile REQUIRED)
# XDR stuff
- IF(NOT WIN32)
- FIND_PACKAGE(SalomeXDR REQUIRED)
- ELSE(NOT WIN32)
- IF(MEDCOUPLING_MEDLOADER_USE_XDR)
+ IF(MEDCOUPLING_MEDLOADER_USE_XDR)
FIND_PACKAGE(SalomeXDR REQUIRED)
- ENDIF(MEDCOUPLING_MEDLOADER_USE_XDR)
- ENDIF(NOT WIN32)
+ ENDIF(MEDCOUPLING_MEDLOADER_USE_XDR)
# End of XDR Stuff
IF(MEDCOUPLING_ENABLE_PARTITIONER)
FIND_PACKAGE(SalomeLibXml2)
IF(MEDCOUPLING_PARTITIONER_METIS)
FIND_PACKAGE(SalomeMetis)
SALOME_LOG_OPTIONAL_PACKAGE(Metis MEDCOUPLING_PARTITIONER_METIS)
- ADD_DEFINITIONS("-DMED_ENABLE_METIS")
+ IF(SalomeMetis_FOUND)
+ ADD_DEFINITIONS("-DMED_ENABLE_METIS")
+ ENDIF()
ENDIF(MEDCOUPLING_PARTITIONER_METIS)
IF(MEDCOUPLING_PARTITIONER_SCOTCH)
FIND_PACKAGE(SalomeScotch)
SALOME_LOG_OPTIONAL_PACKAGE(Scotch MEDCOUPLING_PARTITIONER_SCOTCH)
- ADD_DEFINITIONS("-DMED_ENABLE_SCOTCH")
+ IF(SalomeScotch_FOUND)
+ ADD_DEFINITIONS("-DMED_ENABLE_SCOTCH")
+ ENDIF()
ENDIF(MEDCOUPLING_PARTITIONER_SCOTCH)
ENDIF(MEDCOUPLING_ENABLE_PARTITIONER)
ENDIF(NOT MEDCOUPLING_MICROMED)
IF(MEDCOUPLING_USE_MPI)
FIND_PACKAGE(SalomeMPI REQUIRED)
ADD_DEFINITIONS("-DHAVE_MPI")
+ SALOME_ADD_MPI_TO_HDF5()
IF(MEDCOUPLING_PARTITIONER_PARMETIS)
FIND_PACKAGE(SalomeParMetis)
SALOME_LOG_OPTIONAL_PACKAGE(ParMetis MEDCOUPLING_PARTITIONER_PARMETIS)
- ADD_DEFINITIONS("-DMED_ENABLE_PARMETIS")
+ IF (SalomeParMetis_FOUND)
+ ADD_DEFINITIONS("-DMED_ENABLE_PARMETIS")
+ ENDIF()
ENDIF(MEDCOUPLING_PARTITIONER_PARMETIS)
+ IF(MEDCOUPLING_PARTITIONER_PTSCOTCH)
+ FIND_PACKAGE(SalomePTScotch)
+ SALOME_LOG_OPTIONAL_PACKAGE(PTScotch MEDCOUPLING_PARTITIONER_PTSCOTCH)
+ IF(SalomePTScotch_FOUND)
+ ADD_DEFINITIONS("-DMED_ENABLE_PTSCOTCH")
+ ENDIF(SalomePTScotch_FOUND)
+ ENDIF(MEDCOUPLING_PARTITIONER_PTSCOTCH)
ENDIF(MEDCOUPLING_USE_MPI)
IF(MEDCOUPLING_ENABLE_RENUMBER)
ENDIF(MEDCOUPLING_ENABLE_RENUMBER)
IF(MEDCOUPLING_ENABLE_PYTHON)
- FIND_PACKAGE(SalomePython)
+ FIND_PACKAGE(SalomePythonInterp)
+ FIND_PACKAGE(SalomePythonLibs)
+ FIND_PACKAGE(SalomeNumPySciPy)
FIND_PACKAGE(SalomeSWIG)
- SALOME_LOG_OPTIONAL_PACKAGE(Python MEDCOUPLING_ENABLE_PYTHON)
+ SALOME_LOG_OPTIONAL_PACKAGE(PythonInterp MEDCOUPLING_ENABLE_PYTHON)
+ SALOME_LOG_OPTIONAL_PACKAGE(PythonLibs MEDCOUPLING_ENABLE_PYTHON)
SALOME_LOG_OPTIONAL_PACKAGE(SWIG MEDCOUPLING_ENABLE_PYTHON)
- # Set the extra flags for SWIG for numpy and scipy
- SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY)
- IF(NUMPY_FOUND)
- SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "-DWITH_NUMPY")
- ENDIF(NUMPY_FOUND)
- IF(SCIPY_FOUND)
- SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY};-DWITH_SCIPY")
- ENDIF(SCIPY_FOUND)
+ IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "2")
+ IF("${PYTHON_VERSION_MINOR}" LESS "7")
+ MESSAGE(FATAL_ERROR "MEDCoupling's Python requires at least Python 2.7 (you seem to have ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}). Upgrade your Python, or turn off MEDCOUPLING_ENABLE_PYTHON")
+ ENDIF()
+ ENDIF()
+ IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ MESSAGE(STATUS "Using Python 3")
+ ENDIF()
ENDIF(MEDCOUPLING_ENABLE_PYTHON)
IF(MEDCOUPLING_BUILD_DOC)
# Header configuration
# ====================
SALOME_XVERSION(${PROJECT_NAME})
-SALOME_CONFIGURE_FILE(MEDCoupling_version.h.in MEDCoupling_version.h INSTALL ${SALOME_INSTALL_HEADERS})
-#SALOME_CONFIGURE_FILE(VERSION.in VERSION INSTALL ${SALOME_INSTALL_BINS})
+SALOME_CONFIGURE_FILE(MEDCoupling_version.h.in MEDCoupling_version.h INSTALL ${MEDCOUPLING_INSTALL_HEADERS})
# Accumulate environment variables for MED module
#SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${MEDCOUPLING_INSTALL_BINS}
ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
ENDIF(WIN32)
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
+
ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(cmake_files)
+ADD_SUBDIRECTORY(adm_local)
IF(MEDCOUPLING_BUILD_DOC)
ADD_SUBDIRECTORY(doc)
ENDIF(MEDCOUPLING_BUILD_DOC)
-IF(NOT MEDCOUPLING_MICROMED)
- IF(MEDCOUPLING_WITH_FILE_EXAMPLES)
- ADD_SUBDIRECTORY(resources)
- ENDIF(MEDCOUPLING_WITH_FILE_EXAMPLES)
-ENDIF(NOT MEDCOUPLING_MICROMED)
+ADD_SUBDIRECTORY(resources)
+IF(MEDCOUPLING_ENABLE_PYTHON)
+ ADD_SUBDIRECTORY(v8_work)
+ENDIF()
# Configuration export
# ====================
# List of targets in this project we want to make visible to the rest of the world.
# They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
SET(_${PROJECT_NAME}_exposed_targets
- interpkernel medcoupling medcouplingremapper)
+ interpkernel medcouplingcpp medcouplingremapper medicoco)
IF(NOT MEDCOUPLING_MICROMED)
LIST(APPEND _${PROJECT_NAME}_exposed_targets medloader)