Skip to content
Snippets Groups Projects
Commit 27603b0e authored by Lars Bilke's avatar Lars Bilke
Browse files

[CMake] Better ctest dependency handling.

Allows for e.g. utils only tests with:

```
-DOGS_BUILD_UTILS=ON -DOGS_BUILD_CLI=OFF
```

EXECUTABLE argument is now required on AddTest().
parent 383a4a29
No related branches found
No related tags found
No related merge requests found
...@@ -321,6 +321,9 @@ if(PARSL AND NOT OGS_USE_MPI) ...@@ -321,6 +321,9 @@ if(PARSL AND NOT OGS_USE_MPI)
set_tests_properties(parsl_ExtractBoundary PROPERTIES DEPENDS snakemake_ExtractBoundary) set_tests_properties(parsl_ExtractBoundary PROPERTIES DEPENDS snakemake_ExtractBoundary)
endif() endif()
endif() endif()
if(SNAKEMAKE OR PARSL)
add_dependencies(ctest ExtractBoundary)
endif()
AddTest( AddTest(
NAME partmesh_with_field_data NAME partmesh_with_field_data
......
...@@ -3,6 +3,15 @@ if(OGS_USE_XDMF) ...@@ -3,6 +3,15 @@ if(OGS_USE_XDMF)
add_subdirectory(xdmfdiff) add_subdirectory(xdmfdiff)
endif() endif()
### ctest dependencies
foreach(tool vtkdiff xdmfdiff)
if(TARGET ${tool})
list(APPEND test_dependencies ${tool})
endif()
endforeach()
add_dependencies(ctest ${test_dependencies})
add_dependencies(ctest-large ${test_dependencies})
### testrunner ### ### testrunner ###
include(${PROJECT_SOURCE_DIR}/scripts/cmake/OGSEnabledElements.cmake) include(${PROJECT_SOURCE_DIR}/scripts/cmake/OGSEnabledElements.cmake)
......
...@@ -33,6 +33,9 @@ set(OGS_BUILD_PROCESSES ...@@ -33,6 +33,9 @@ set(OGS_BUILD_PROCESSES
CACHE STRING "Semicolon-separated list of processes to build") CACHE STRING "Semicolon-separated list of processes to build")
if(NOT OGS_BUILD_CLI) if(NOT OGS_BUILD_CLI)
set(OGS_BUILD_PROCESSES OFF "" CACHE INTERNAL "") set(OGS_BUILD_PROCESSES OFF "" CACHE INTERNAL "")
message(STATUS "ATTENTION: OGS_BUILD_CLI=OFF -> OGS_BUILD_PROCESSES is set to OFF too.\n"
" If cli is switched on again, remember to switch processes back to on \n"
" too with -DOGS_BUILD_PROCESSES=\"\"!")
endif() endif()
if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "") if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "")
if(${OGS_BUILD_PROCESSES}) if(${OGS_BUILD_PROCESSES})
......
...@@ -60,7 +60,7 @@ function (AddTest) ...@@ -60,7 +60,7 @@ function (AddTest)
# set defaults # set defaults
if(NOT DEFINED AddTest_EXECUTABLE) if(NOT DEFINED AddTest_EXECUTABLE)
set(AddTest_EXECUTABLE ogs) message(FATAL_ERROR "Test ${AddTest_NAME}: No EXECUTABLE set!")
endif() endif()
if (NOT DEFINED AddTest_REQUIREMENTS) if (NOT DEFINED AddTest_REQUIREMENTS)
set(AddTest_REQUIREMENTS TRUE) set(AddTest_REQUIREMENTS TRUE)
...@@ -82,6 +82,11 @@ function (AddTest) ...@@ -82,6 +82,11 @@ function (AddTest)
endif() endif()
# --- Implement wrappers --- # --- Implement wrappers ---
# check if exe is part of build
if(NOT TARGET ${AddTest_EXECUTABLE})
set(DISABLED_TESTS_LOG "${DISABLED_TESTS_LOG}\nTest exe ${AddTest_EXECUTABLE} not built! Disabling test ${AddTest_NAME}." CACHE INTERNAL "")
return()
endif()
# check requirements, disable if not met # check requirements, disable if not met
if(${AddTest_REQUIREMENTS}) if(${AddTest_REQUIREMENTS})
message(DEBUG "Enabling test ${AddTest_NAME}.") message(DEBUG "Enabling test ${AddTest_NAME}.")
...@@ -285,10 +290,8 @@ Use six arguments version of AddTest with absolute and relative tolerances") ...@@ -285,10 +290,8 @@ Use six arguments version of AddTest with absolute and relative tolerances")
LABELS "${DIR_LABELS}" LABELS "${DIR_LABELS}"
) )
if(NOT "${AddTest_EXECUTABLE}" STREQUAL "ogs" AND TARGET ${AddTest_EXECUTABLE}) add_dependencies(ctest ${AddTest_EXECUTABLE})
add_dependencies(ctest ${AddTest_EXECUTABLE}) add_dependencies(ctest-large ${AddTest_EXECUTABLE})
add_dependencies(ctest-large ${AddTest_EXECUTABLE})
endif()
if(AddTest_PYTHON_PACKAGES) if(AddTest_PYTHON_PACKAGES)
if(POETRY) if(POETRY)
......
...@@ -36,11 +36,8 @@ if(CMAKE_CONFIGURATION_TYPES) ...@@ -36,11 +36,8 @@ if(CMAKE_CONFIGURATION_TYPES)
endif() endif()
add_custom_target(ctest-cleanup ${CMAKE_COMMAND} -E remove -f Tests/ctest.log) add_custom_target(ctest-cleanup ${CMAKE_COMMAND} -E remove -f Tests/ctest.log)
set(test_dependencies ogs vtkdiff)
if(OGS_BUILD_UTILS) if(OGS_BUILD_UTILS)
list(APPEND test_dependencies list(APPEND test_dependencies
partmesh
MapGeometryToMeshSurface
generateStructuredMesh generateStructuredMesh
) )
endif() endif()
...@@ -92,7 +89,4 @@ set_directory_properties(PROPERTIES ...@@ -92,7 +89,4 @@ set_directory_properties(PROPERTIES
set_target_properties(ctest ctest-large ctest-cleanup ctest-large-cleanup set_target_properties(ctest ctest-large ctest-cleanup ctest-large-cleanup
PROPERTIES FOLDER Testing) PROPERTIES FOLDER Testing)
add_dependencies(ctest ogs)
add_dependencies(ctest-large ogs)
configure_file(${PROJECT_SOURCE_DIR}/scripts/test/buildinfo.in.yaml ${PROJECT_BINARY_DIR}/buildinfo.yaml) configure_file(${PROJECT_SOURCE_DIR}/scripts/test/buildinfo.in.yaml ${PROJECT_BINARY_DIR}/buildinfo.yaml)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment