]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/ParaMEDMEM_Swig/CMakeLists.txt
Salome HOME
Merge branch 'V9_11_BR'
[tools/medcoupling.git] / src / ParaMEDMEM_Swig / CMakeLists.txt
1 # Copyright (C) 2012-2023  CEA, EDF
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
21
22 IF (NOT DEFINED MSVC)
23   ADD_DEFINITIONS(-Wsign-compare -Wconversion)
24 ENDIF()
25
26 FIND_PACKAGE(SWIG REQUIRED)
27 INCLUDE(${SWIG_USE_FILE})
28
29 SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES CPLUSPLUS ON)
30 IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
31   SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_FLAGS "-py3")
32 ELSE()
33   SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_DEFINITIONS "-shadow")
34 ENDIF()
35 SET(SWIG_MODULE_ParaMEDMEM_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
36 IF(MEDCOUPLING_USE_64BIT_IDS)
37   STRING(APPEND SWIG_MODULE_ParaMEDMEM_EXTRA_FLAGS ";-DMEDCOUPLING_USE_64BIT_IDS")
38 ENDIF(MEDCOUPLING_USE_64BIT_IDS)
39
40 INCLUDE_DIRECTORIES(
41   ${PYTHON_INCLUDE_DIRS}
42   ${NUMPY_INCLUDE_DIR}
43   ${MPI_INCLUDE_DIRS}
44   ${CMAKE_CURRENT_SOURCE_DIR}
45   ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM
46   ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM/MPIAccess
47   ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo
48   ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/Swig
49   ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling_Swig
50   ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling
51   ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL
52   ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases
53   )
54
55 SET (SWIG_MODULE_ParaMEDMEM_EXTRA_DEPS
56     ${paramedmem_HEADERS_HXX}
57     ${medloader_HEADERS_HXX}
58     ${medcoupling_HEADERS_HXX} ${medcoupling_HEADERS_TXX}
59     ${interpkernel_HEADERS_HXX} ${interpkernel_HEADERS_TXX})
60
61 IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
62   SWIG_ADD_MODULE(ParaMEDMEM python ParaMEDMEM.i)
63 ELSE()
64   SWIG_ADD_LIBRARY(ParaMEDMEM LANGUAGE python SOURCES ParaMEDMEM.i)
65 ENDIF()
66
67 SWIG_LINK_LIBRARIES(ParaMEDMEM ${PYTHON_LIBRARIES} paramedmem)
68 SWIG_CHECK_GENERATION(ParaMEDMEM)
69
70 #
71 # Tests
72 #
73 IF(MEDCOUPLING_BUILD_PY_TESTS)
74     SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_CURRENT_BINARY_DIR}/../PyWrapping)
75     SALOME_ACCUMULATE_ENVIRONMENT(MED_RESOURCES_DIR NOCHECK ${CMAKE_SOURCE_DIR}/resources)
76     SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
77     
78     #  -- some tests require 2, 3, 4 or 5 procs --
79     # MPICH does not support --oversubscribe:
80     IF(NOT ${MPIEXEC_EXECUTABLE} MATCHES "mpich")
81         SET(_oversub_opt "--oversubscribe")
82     ENDIF()
83     
84     ADD_TEST(NAME PyPara_Basics_Proc2
85              COMMAND ${MPIEXEC} -np 2  ${_oversub_opt} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_BasicOperation.py)
86     SET_TESTS_PROPERTIES(PyPara_Basics_Proc2 PROPERTIES ENVIRONMENT "${tests_env}")
87     
88     ADD_TEST(NAME PyPara_InterpKernelDEC_Proc4
89              COMMAND ${MPIEXEC} -np 4  ${_oversub_opt} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_InterpKernelDEC.py)
90     SET_TESTS_PROPERTIES(PyPara_InterpKernelDEC_Proc4 PROPERTIES ENVIRONMENT "${tests_env}")
91     ADD_TEST(NAME PyPara_InterpKernelDEC_Proc5
92              COMMAND ${MPIEXEC} -np 5  ${_oversub_opt} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_InterpKernelDEC.py)
93     SET_TESTS_PROPERTIES(PyPara_InterpKernelDEC_Proc5 PROPERTIES ENVIRONMENT "${tests_env}")
94     
95     #ADD_TEST(NAME PyPara_NonCoincidentDEC_Proc5
96     #         COMMAND ${MPIEXEC} -np 5  ${_oversub_opt} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_NonCoincidentDEC.py)
97     #SET_TESTS_PROPERTIES(PyPara_NonCoincidentDEC_Proc5 PROPERTIES ENVIRONMENT "${tests_env}")
98     
99     ADD_TEST(NAME PyPara_StructuredCoincidentDEC_Proc4
100              COMMAND ${MPIEXEC} -np 4  ${_oversub_opt} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_StructuredCoincidentDEC.py)
101     SET_TESTS_PROPERTIES(PyPara_StructuredCoincidentDEC_Proc4 PROPERTIES ENVIRONMENT "${tests_env}")
102     
103     ADD_TEST(NAME PyPara_OverlapDEC_Proc4
104              COMMAND ${MPIEXEC} -np 4  ${_oversub_opt} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_OverlapDEC.py)
105     SET_TESTS_PROPERTIES(PyPara_OverlapDEC_Proc4 PROPERTIES ENVIRONMENT "${tests_env}")
106 ENDIF()
107
108 SET(_tst_scripts
109   test_InterpKernelDEC.py
110   test_NonCoincidentDEC.py
111   test_StructuredCoincidentDEC.py
112   test_OverlapDEC.py
113 )
114
115 INSTALL(TARGETS _ParaMEDMEM DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
116 INSTALL(FILES ParaMEDMEM.i ParaMEDMEMCommon.i DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
117 INSTALL(FILES ${_tst_scripts} DESTINATION ${MEDCOUPLING_INSTALL_SCRIPT_PYTHON})
118 SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/ParaMEDMEM.py ${MEDCOUPLING_INSTALL_PYTHON} EXTRA_DPYS "${SWIG_MODULE_ParaMEDMEM_REAL_NAME}")
119
120 INSTALL(FILES test_InterpKernelDEC.py test_NonCoincidentDEC.py test_StructuredCoincidentDEC.py DESTINATION ${MEDCOUPLING_INSTALL_SCRIPT_PYTHON})
121
122 set(TEST_INSTALL_DIRECTORY ${MEDCOUPLING_INSTALL_TESTS}/ParaMEDMEM_Swig)
123 install(FILES test_InterpKernelDEC.py test_NonCoincidentDEC.py test_OverlapDEC.py test_StructuredCoincidentDEC.py ParaMEDMEMTestTools.py test_BasicOperation.py DESTINATION ${TEST_INSTALL_DIRECTORY})
124 # export MPIEXEC and _oversub_opt to CTestTestfile.cmake of salome test mechanism
125 configure_file(CTestTestfileInstall.cmake.in "CTestTestfileST.cmake" @ONLY)
126 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileST.cmake DESTINATION ${TEST_INSTALL_DIRECTORY} RENAME CTestTestfile.cmake)