Skip to content

Commit

Permalink
use TEST_LAUNCHER for CMake 3.29+
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Dec 14, 2023
1 parent 8ba4f60 commit 2d38d04
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 61 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ enable_testing()

include(cmake/compilers.cmake)

add_subdirectory(src)
add_subdirectory(test)

file(GENERATE OUTPUT .gitignore CONTENT "*")
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ endif

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

subdir('src')
subdir('test')
59 changes: 0 additions & 59 deletions src/CMakeLists.txt

This file was deleted.

62 changes: 62 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
add_executable(mpi_basic_C basic.c)
target_link_libraries(mpi_basic_C PRIVATE MPI::MPI_C)
add_test(NAME mpi_basic_C COMMAND mpi_basic_C)

add_executable(mpi_version_C mpivers.c)
target_link_libraries(mpi_version_C PRIVATE MPI::MPI_C)
add_test(NAME mpi_version_C COMMAND mpi_version_C)

# --- Fortran MPI-3

add_executable(mpi_basic_Fortran basic.f90)
target_link_libraries(mpi_basic_Fortran PRIVATE MPI::MPI_Fortran)
add_test(NAME mpi_basic_Fortran COMMAND mpi_basic_Fortran)

add_executable(mpi_version_Fortran mpivers.f90)
target_link_libraries(mpi_version_Fortran PRIVATE MPI::MPI_Fortran)
add_test(NAME mpi_version_Fortran COMMAND mpi_version_Fortran)

# --- more than one MPI image

add_executable(mpi_hello helloworld.f90)
target_link_libraries(mpi_hello PRIVATE MPI::MPI_Fortran)
add_test(NAME mpi_hello COMMAND mpi_hello)
set_property(TEST mpi_hello PROPERTY FIXTURES_SETUP mpi_fxt)

# --- actual message passing

add_executable(mpi_pass thread_pass.f90)
target_link_libraries(mpi_pass PRIVATE MPI::MPI_Fortran)

if(MPIEXEC_MAX_NUMPROCS GREATER_EQUAL 2)

add_test(NAME mpi_pass COMMAND mpi_pass)
set_property(TEST mpi_pass PROPERTY FIXTURES_REQUIRED mpi_fxt)

endif()


get_property(tests DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
set_property(TEST ${tests} PROPERTY cpu_mpi)

# convenience vars
set(single mpi_basic_C mpi_version_C mpi_basic_Fortran mpi_version_Fortran)
set(_m ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG})

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)

set_property(TEST ${single} PROPERTY TEST_LAUNCHER ${_m} 1)
set_property(TEST mpi_hello PROPERTY TEST_LAUNCHER ${_m} ${MPIEXEC_MAX_NUMPROCS})
set_property(TEST mpi_pass PROPERTY TEST_LAUNCHER ${_m} 2)

else()

set_property(TARGET ${single} PROPERTY CROSSCOMPILING_EMULATOR ${_m} 1)
set_property(TARGET mpi_hello PROPERTY CROSSCOMPILING_EMULATOR ${_m} ${MPIEXEC_MAX_NUMPROCS})
set_property(TARGET mpi_pass PROPERTY CROSSCOMPILING_EMULATOR ${_m} 2)

endif()

if(DEFINED mpi_tmpdir)
set_property(TEST ${tests} PROPERTY ENVIRONMENT TMPDIR=${mpi_tmpdir})
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.
File renamed without changes.

0 comments on commit 2d38d04

Please sign in to comment.