From c02ef4d8b1b98e995511386eef3b8c4e48323ac8 Mon Sep 17 00:00:00 2001
From: Christian Godenschwager <christian.godenschwager@fau.de>
Date: Fri, 13 Oct 2017 16:07:54 +0200
Subject: [PATCH] CMake: walberla_execute_test accepts new parameter
 DEPENDS_ON_TARGETS

DEPENDS_ON_TARGETS defines a list of targets that a test depends on. If any of the targets is not built, the test will not be added to test suite.
---
 apps/benchmarks/ComplexGeometry/CMakeLists.txt |  2 +-
 cmake/waLBerlaFunctions.cmake                  | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/apps/benchmarks/ComplexGeometry/CMakeLists.txt b/apps/benchmarks/ComplexGeometry/CMakeLists.txt
index 583b9426..9325acb3 100644
--- a/apps/benchmarks/ComplexGeometry/CMakeLists.txt
+++ b/apps/benchmarks/ComplexGeometry/CMakeLists.txt
@@ -9,6 +9,6 @@ if ( WALBERLA_BUILD_WITH_OPENMESH )
 	# Some tests #
 	##############
 
-	waLBerla_execute_test( NO_MODULE_LABEL NAME ComplexGeometry COMMAND $<TARGET_FILE:ComplexGeometry> input.conf )
+	waLBerla_execute_test( NO_MODULE_LABEL NAME ComplexGeometry COMMAND $<TARGET_FILE:ComplexGeometry> input.conf DEPENDS_ON_TARGETS ComplexGeometry )
 endif()
 
diff --git a/cmake/waLBerlaFunctions.cmake b/cmake/waLBerlaFunctions.cmake
index 320afbb1..59f62991 100644
--- a/cmake/waLBerlaFunctions.cmake
+++ b/cmake/waLBerlaFunctions.cmake
@@ -335,7 +335,7 @@ function ( waLBerla_execute_test )
     
    set( options NO_MODULE_LABEL )
    set( oneValueArgs NAME PROCESSES )
-   set( multiValueArgs COMMAND LABELS CONFIGURATIONS )
+   set( multiValueArgs COMMAND LABELS CONFIGURATIONS DEPENDS_ON_TARGETS )
    cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
 
    if( NOT ARG_NAME )
@@ -343,9 +343,16 @@ function ( waLBerla_execute_test )
    endif()
    
    if( NOT ARG_COMMAND AND NOT TARGET ${ARG_NAME} )
-      message ( STATUS "Skipping ${ARG_NAME} since the corresponding test was not built" )
+      message ( STATUS "Skipping test ${ARG_NAME} since the corresponding target is not built" )
       return()
-   endif()  
+   endif() 
+
+   foreach( dependency_target ${ARG_DEPENDS_ON_TARGETS} )
+      if( NOT TARGET ${dependency_target} )
+         message ( STATUS "Skipping test ${ARG_NAME} since the target ${dependency_target} is not built" )
+         return()
+      endif()
+   endforeach( dependency_target )
    
    if( NOT ARG_PROCESSES )
       set ( numProcesses 1 )
-- 
GitLab