diff --git a/CMake/mitkFunctionAddCustomModuleTest.cmake b/CMake/mitkFunctionAddCustomModuleTest.cmake index 1d7bd363cf..f30e754773 100644 --- a/CMake/mitkFunctionAddCustomModuleTest.cmake +++ b/CMake/mitkFunctionAddCustomModuleTest.cmake @@ -1,12 +1,16 @@ #! #! \brief Add a custom test for MITK module #! #! \param test_name Unique identifier for the test #! \param test_function Name of the test function (the one with the argc,argv signature) #! #! Additional parameters will be passed as command line parameters to the test. #! function(mitkAddCustomModuleTest test_name test_function) - add_test(${test_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${test_function} ${ARGN}) - set_property(TEST ${test_name} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) + + if (BUILD_TESTING AND NOT ${MODULE_NAME}_IS_ENABLED) + add_test(${test_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${test_function} ${ARGN}) + set_property(TEST ${test_name} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) + endif() + endfunction()