Refine the CMakeLists.txt for MPI gmxapi tests.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Fri, 11 Sep 2020 13:47:56 +0000 (16:47 +0300)
committerPaul Bauer <paul.bauer.q@gmail.com>
Mon, 14 Sep 2020 06:39:38 +0000 (06:39 +0000)
Exclude tests when GMX_MPI is not set. Normalize test working directory.

src/api/cpp/tests/CMakeLists.txt
src/api/cpp/workflow/tests/CMakeLists.txt

index e674ac44e62f765512797c05e21648084bde5382..ee3f1ed8b5de05c3518785dfb51dfbd4e48993a3 100644 (file)
@@ -79,26 +79,37 @@ set_tests_properties(GmxapiExternalInterfaceTests PROPERTIES
 #
 # Test public interface with MPI.
 #
+# gmxapi is expected to work whether or not GROMACS was built with MPI (or tMPI)
+# but we don't assume that MPI is available to the build tree or testing tools
+# unless CMake was configured with MPI.
+#
+# For MPI-enabled testing of gmxapi clients using non-MPI-enabled GROMACS, we
+# defer testing to the Python gmxapi client package tests.
+#
+if (GMX_MPI)
+    gmx_add_gtest_executable(gmxapi-mpi-test MPI
+                             CPP_SOURCE_FILES
+                             restraint.cpp
+                             status.cpp
+                             system.cpp
+                             version.cpp
+                             # pseudo-library for code for mdrun
+                             $<TARGET_OBJECTS:mdrun_objlib>
+                             )
+    if(NOT GMX_GPU_OPENCL)
+        # GPU resources may not be properly reinitialized between simulations in
+        # the same process.
+        # TODO: include this with the other test sources once the issue is resolved
+        # Ref https://gitlab.com/gromacs/gromacs/-/issues/2689
+        target_sources(gmxapi-mpi-test PRIVATE runner.cpp stopsignaler.cpp)
+    endif()
 
-gmx_add_gtest_executable(gmxapi-mpi-test MPI
-    CPP_SOURCE_FILES
-        restraint.cpp
-        status.cpp
-        system.cpp
-        version.cpp
-        # pseudo-library for code for mdrun
-        $<TARGET_OBJECTS:mdrun_objlib>
-        )
-if(NOT GMX_GPU_OPENCL)
-    # GPU resources may not be properly reinitialized between simulations in
-    # the same process.
-    # TODO: include this with the other test sources once the issue is resolved
-    # Ref https://gitlab.com/gromacs/gromacs/-/issues/2689
-    target_sources(gmxapi-mpi-test PRIVATE runner.cpp stopsignaler.cpp)
-endif()
+    target_include_directories(gmxapi-mpi-test PRIVATE
+                               ${CMAKE_CURRENT_SOURCE_DIR})
+    target_link_libraries(gmxapi-mpi-test PRIVATE Gromacs::gmxapi gmxapi-testsupport mdrun_test_infrastructure)
 
-target_include_directories(gmxapi-mpi-test PRIVATE
-                           ${CMAKE_CURRENT_SOURCE_DIR})
-target_link_libraries(gmxapi-mpi-test PRIVATE Gromacs::gmxapi gmxapi-testsupport mdrun_test_infrastructure)
+    gmx_register_gtest_test(GmxapiMpiTests gmxapi-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
 
-gmx_register_gtest_test(GmxapiMpiTests gmxapi-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
+    set_tests_properties(GmxapiMpiTests PROPERTIES
+                         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+endif ()
index edf78badb5b9f8dc0ae7c638daf88b7340639acf..65074a7f149f5032faeca7d4a0c29d04b364f5bb 100644 (file)
@@ -57,19 +57,30 @@ set_tests_properties(GmxapiInternalInterfaceTests PROPERTIES
 #
 # Test with MPI.
 #
+# gmxapi is expected to work whether or not GROMACS was built with MPI (or tMPI)
+# but we don't assume that MPI is available to the build tree or testing tools
+# unless CMake was configured with MPI.
+#
+# For MPI-enabled testing of gmxapi clients using non-MPI-enabled GROMACS, we
+# defer testing to the Python gmxapi client package tests.
+#
+if (GMX_MPI)
+    gmx_add_gtest_executable(workflow-details-mpi-test MPI
+                             CPP_SOURCE_FILES
+                             workflow.cpp
+                             # pseudo-library for code for mdrun
+                             $<TARGET_OBJECTS:mdrun_objlib>
+                             )
 
-gmx_add_gtest_executable(workflow-details-mpi-test MPI
-    CPP_SOURCE_FILES
-        workflow.cpp
-        # pseudo-library for code for mdrun
-        $<TARGET_OBJECTS:mdrun_objlib>
-)
+    target_link_libraries(workflow-details-mpi-test
+                          PRIVATE
+                          Gromacs::gmxapi
+                          gmxapi-detail
+                          gmxapi-testsupport
+                          mdrun_test_infrastructure)
 
-target_link_libraries(workflow-details-mpi-test
-                      PRIVATE
-                        Gromacs::gmxapi
-                        gmxapi-detail
-                        gmxapi-testsupport
-                        mdrun_test_infrastructure)
+    gmx_register_gtest_test(GmxapiInternalsMpiTests workflow-details-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
 
-gmx_register_gtest_test(GmxapiInternalsMpiTests workflow-details-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
+    set_tests_properties(GmxapiInternalsMpiTests PROPERTIES
+                         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+endif ()