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