Skip to content

Commit 7c47f71

Browse files
committed
use TEST_LAUNCHER for CMake 3.29+
1 parent 8d7f132 commit 7c47f71

File tree

11 files changed

+64
-61
lines changed

11 files changed

+64
-61
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ enable_testing()
88

99
include(cmake/compilers.cmake)
1010

11-
add_subdirectory(src)
11+
add_subdirectory(test)
1212

1313
file(GENERATE OUTPUT .gitignore CONTENT "*")

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ endif
1818

1919
mpiexec = find_program('mpiexec', required : false, disabler: true) # MS-MPI has only mpiexec
2020

21-
subdir('src')
21+
subdir('test')

src/CMakeLists.txt

Lines changed: 0 additions & 59 deletions
This file was deleted.

test/CMakeLists.txt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
add_executable(mpi_basic_C basic.c)
2+
target_link_libraries(mpi_basic_C PRIVATE MPI::MPI_C)
3+
add_test(NAME mpi_basic_C COMMAND mpi_basic_C)
4+
5+
add_executable(mpi_version_C mpivers.c)
6+
target_link_libraries(mpi_version_C PRIVATE MPI::MPI_C)
7+
add_test(NAME mpi_version_C COMMAND mpi_version_C)
8+
9+
# --- Fortran MPI-3
10+
11+
add_executable(mpi_basic_Fortran basic.f90)
12+
target_link_libraries(mpi_basic_Fortran PRIVATE MPI::MPI_Fortran)
13+
add_test(NAME mpi_basic_Fortran COMMAND mpi_basic_Fortran)
14+
15+
add_executable(mpi_version_Fortran mpivers.f90)
16+
target_link_libraries(mpi_version_Fortran PRIVATE MPI::MPI_Fortran)
17+
add_test(NAME mpi_version_Fortran COMMAND mpi_version_Fortran)
18+
19+
# --- more than one MPI image
20+
21+
add_executable(mpi_hello helloworld.f90)
22+
target_link_libraries(mpi_hello PRIVATE MPI::MPI_Fortran)
23+
add_test(NAME mpi_hello COMMAND mpi_hello)
24+
set_property(TEST mpi_hello PROPERTY FIXTURES_SETUP mpi_fxt)
25+
26+
# --- actual message passing
27+
28+
add_executable(mpi_pass thread_pass.f90)
29+
target_link_libraries(mpi_pass PRIVATE MPI::MPI_Fortran)
30+
31+
if(MPIEXEC_MAX_NUMPROCS GREATER_EQUAL 2)
32+
33+
add_test(NAME mpi_pass COMMAND mpi_pass)
34+
set_property(TEST mpi_pass PROPERTY FIXTURES_REQUIRED mpi_fxt)
35+
36+
endif()
37+
38+
39+
get_property(tests DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
40+
set_property(TEST ${tests} PROPERTY cpu_mpi)
41+
42+
# convenience vars
43+
set(single mpi_basic_C mpi_version_C mpi_basic_Fortran mpi_version_Fortran)
44+
set(_m ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG})
45+
46+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)
47+
48+
set_property(TEST ${single} PROPERTY TEST_LAUNCHER ${_m} 1)
49+
set_property(TEST mpi_hello PROPERTY TEST_LAUNCHER ${_m} ${MPIEXEC_MAX_NUMPROCS})
50+
set_property(TEST mpi_pass PROPERTY TEST_LAUNCHER ${_m} 2)
51+
52+
else()
53+
54+
set_property(TARGET ${single} PROPERTY CROSSCOMPILING_EMULATOR ${_m} 1)
55+
set_property(TARGET mpi_hello PROPERTY CROSSCOMPILING_EMULATOR ${_m} ${MPIEXEC_MAX_NUMPROCS})
56+
set_property(TARGET mpi_pass PROPERTY CROSSCOMPILING_EMULATOR ${_m} 2)
57+
58+
endif()
59+
60+
if(DEFINED mpi_tmpdir)
61+
set_property(TEST ${tests} PROPERTY ENVIRONMENT TMPDIR=${mpi_tmpdir})
62+
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)