-# Copyright (C) 2012-2016 CEA/DEN, EDF R&D
+# Copyright (C) 2012-2024 CEA, EDF
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${HDF5_DEFINITIONS} ${MEDFILE_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
+IF (NOT DEFINED MSVC)
+ ADD_DEFINITIONS(-Wsign-compare -Wconversion)
+ENDIF()
+
SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+ SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
SET(SWIG_MODULE_MEDPartitioner_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS};-DWITHOUT_AUTOFIELD")
SET (MEDPartitioner_SWIG_DPYS_FILES
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_DIRS}
- ${PTHREAD_INCLUDE_DIR} # pthread dependancy due to python2.7 library
+ ${PTHREAD_INCLUDE_DIR} # pthread dependency due to python2.7 library
${NUMPY_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints
)
-SWIG_ADD_MODULE(MEDPartitioner python MEDPartitioner.i)
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(MEDPartitioner python MEDPartitioner.i)
+ELSE()
+ SWIG_ADD_LIBRARY(MEDPartitioner LANGUAGE python SOURCES MEDPartitioner.i)
+ENDIF()
+
SWIG_LINK_LIBRARIES(MEDPartitioner ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medpartitionercpp)
+SWIG_CHECK_GENERATION(MEDPartitioner)
IF(WIN32)
SET_TARGET_PROPERTIES(_MEDPartitioner PROPERTIES DEBUG_OUTPUT_NAME _MEDPartitioner_d)
INSTALL(TARGETS ${SWIG_MODULE_MEDPartitioner_REAL_NAME} DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDPartitioner.py)
-SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${MEDCOUPLING_INSTALL_SCRIPT_PYTHON})
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${MEDCOUPLING_INSTALL_PYTHON} EXTRA_DPYS "${SWIG_MODULE_MEDPartitioner_REAL_NAME}")
INSTALL(FILES MEDPartitioner.i MEDPartitionerCommon.i DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
INSTALL(FILES MEDPartitionerTest.py DESTINATION ${MEDCOUPLING_INSTALL_SCRIPT_PYTHON})
IF(MEDCOUPLING_PARTITIONER_METIS)
- # Python test of partitionner require METIS or PARMETIS?
- SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR}/../MEDLoader/Swig)
- SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
- ADD_TEST(MEDPartitionerTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDPartitionerTest.py)
- SET_TESTS_PROPERTIES(MEDPartitionerTest PROPERTIES ENVIRONMENT "${tests_env}")
- CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../MEDLoader/Swig/MEDLoaderDataForTest.py ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+ IF(MEDCOUPLING_BUILD_PY_TESTS)
+ # Python test of partitionner require METIS or PARMETIS?
+ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_CURRENT_BINARY_DIR}/../MEDLoader/Swig)
+ SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+ ADD_TEST(MEDPartitionerTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDPartitionerTest.py)
+ SET_TESTS_PROPERTIES(MEDPartitionerTest PROPERTIES ENVIRONMENT "${tests_env}")
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../MEDLoader/Swig/MEDLoaderDataForTest.py ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+ ENDIF()
ENDIF()
# Application tests
-SET(TEST_INSTALL_DIRECTORY ${MEDCOUPLING_INSTALL_SCRIPT_SCRIPTS}/test/MEDCoupling/MEDPartitioner_Swig)
+SET(TEST_INSTALL_DIRECTORY ${MEDCOUPLING_INSTALL_TESTS}/MEDPartitioner_Swig)
INSTALL(FILES MEDPartitionerTest.py DESTINATION ${TEST_INSTALL_DIRECTORY})
INSTALL(FILES CTestTestfileInstall.cmake