Salome HOME
[bos #38048] [EDF] (2023-T3) PARAMEDMEM Ergonomy.
[tools/medcoupling.git] / src / ParaMEDMEMTest / CMakeLists.txt
1 # Copyright (C) 2012-2024  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_SUBDIRECTORY(MPIAccess)   # maybe to delete one day ...
21
22 ADD_DEFINITIONS(${MPI_DEFINITIONS} ${CPPUNIT_DEFINITIONS} ${HDF5_DEFINITIONS} ${MEDFILE_DEFINITIONS})
23
24 INCLUDE_DIRECTORIES(
25   ${MPI_INCLUDE_DIRS}
26   ${MEDFILE_INCLUDE_DIRS}
27   ${HDF5_INCLUDE_DIRS}
28   ${CPPUNIT_INCLUDE_DIRS}
29   ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDLoader
30   ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM
31   ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM/MPIAccess
32   ${CMAKE_CURRENT_SOURCE_DIR}/../MEDLoader
33   ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling
34   ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo
35   ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL
36   ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases
37   ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNELTest   # for TestIKUtils.hxx
38   )
39
40 SET(ParaMEDMEMTest_SOURCES
41   ParaMEDMEMTest.cxx
42   ParaMEDMEMTest_MPIProcessorGroup.cxx
43   ParaMEDMEMTest_ByStringMPIProcessorGroup.cxx
44   ParaMEDMEMTest_BlockTopology.cxx
45   ParaMEDMEMTest_InterpKernelDEC.cxx
46   ParaMEDMEMTest_StructuredCoincidentDEC.cxx
47   ParaMEDMEMTest_ICoco.cxx
48   ParaMEDMEMTest_Gauthier1.cxx
49   ParaMEDMEMTest_FabienAPI.cxx
50   ParaMEDMEMTest_NonCoincidentDEC.cxx
51   ParaMEDMEMTest_OverlapDEC.cxx
52   ParaMEDMEMTest_MEDLoader.cxx
53 )
54
55 ADD_LIBRARY(ParaMEDMEMTest ${ParaMEDMEMTest_SOURCES})
56 SET_TARGET_PROPERTIES(ParaMEDMEMTest PROPERTIES COMPILE_FLAGS "")
57 TARGET_LINK_LIBRARIES(ParaMEDMEMTest paramedmem paramedloader medcouplingremapper InterpKernelTestUtils ${CPPUNIT_LIBRARIES})
58 INSTALL(TARGETS ParaMEDMEMTest DESTINATION ${MEDCOUPLING_INSTALL_LIBS})
59
60 SET(TESTSParaMEDMEM)
61 SET(TestParaMEDMEM_SOURCES
62   TestParaMEDMEM.cxx
63   )
64 LIST(APPEND TESTSParaMEDMEM TestParaMEDMEM)
65
66 SET(test_perf_SOURCES
67   test_perf.cxx
68   )
69 LIST(APPEND TESTSParaMEDMEM test_perf)
70
71 IF(MPI2_IS_OK)
72   SET(ParaMEDMEMTestMPI2_1_SOURCES
73     MPI2Connector.cxx
74     ParaMEDMEMTestMPI2_1.cxx
75     )
76   LIST(APPEND TESTSParaMEDMEM ParaMEDMEMTestMPI2_1)
77
78   SET(ParaMEDMEMTestMPI2_2_SOURCES
79     MPI2Connector.cxx
80     ParaMEDMEMTestMPI2_2.cxx
81     )
82   LIST(APPEND TESTSParaMEDMEM ParaMEDMEMTestMPI2_2)
83 ENDIF(MPI2_IS_OK)
84
85 FOREACH(bintestparamem ${TESTSParaMEDMEM})
86   ADD_EXECUTABLE(${bintestparamem} ${${bintestparamem}_SOURCES})
87   TARGET_LINK_LIBRARIES(${bintestparamem} ParaMEDMEMTest)
88 ENDFOREACH(bintestparamem ${TESTSParaMEDMEM})
89
90 # Now add CMake tests - test_perf, ParaMEDMEMTestMPI2_1 and ParaMEDMEMTestMPI2_2
91 # are left aside, as they are too specific
92 #
93 SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
94
95 #  -- some tests require 2, 3, 4 or 5 procs --
96 # MPICH does not support --oversubscribe:
97 IF(NOT ${MPIEXEC_EXECUTABLE} MATCHES "mpich")
98     SET(_oversub_opt "--oversubscribe")
99 ENDIF()
100
101 ADD_TEST(NAME TestParaMEDMEM_Proc2 COMMAND ${MPIEXEC} -np 2  ${_oversub_opt} $<TARGET_FILE:TestParaMEDMEM>)
102 SET_TESTS_PROPERTIES(TestParaMEDMEM_Proc2 PROPERTIES ENVIRONMENT "${tests_env}")
103 ADD_TEST(NAME TestParaMEDMEM_Proc3 COMMAND ${MPIEXEC} -np 3 ${_oversub_opt} $<TARGET_FILE:TestParaMEDMEM>)
104 SET_TESTS_PROPERTIES(TestParaMEDMEM_Proc3 PROPERTIES ENVIRONMENT "${tests_env}")
105 ADD_TEST(NAME TestParaMEDMEM_Proc4 COMMAND ${MPIEXEC} -np 4 ${_oversub_opt} $<TARGET_FILE:TestParaMEDMEM>)
106 SET_TESTS_PROPERTIES(TestParaMEDMEM_Proc4 PROPERTIES ENVIRONMENT "${tests_env}")
107 ADD_TEST(NAME TestParaMEDMEM_Proc5 COMMAND ${MPIEXEC} -np 5 ${_oversub_opt} $<TARGET_FILE:TestParaMEDMEM>)
108 SET_TESTS_PROPERTIES(TestParaMEDMEM_Proc5 PROPERTIES ENVIRONMENT "${tests_env}")
109
110 # Installation rules
111 INSTALL(TARGETS ${TESTSParaMEDMEM} DESTINATION ${MEDCOUPLING_INSTALL_BINS})
112 SET(COMMON_HEADERS_HXX
113   MPIMainTest.hxx
114   ParaMEDMEMTest.hxx
115   MPI2Connector.hxx
116 )
117 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
118
119 # Application tests
120
121 SET(TEST_INSTALL_DIRECTORY ${MEDCOUPLING_INSTALL_TESTS}/ParaMEDMEMTest)
122 INSTALL(TARGETS ${TESTSParaMEDMEM} DESTINATION ${TEST_INSTALL_DIRECTORY})
123
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)