aboutsummaryrefslogtreecommitdiffstats
path: root/functions.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'functions.cmake')
-rw-r--r--functions.cmake19
1 files changed, 11 insertions, 8 deletions
diff --git a/functions.cmake b/functions.cmake
index c75a454923b..46b8083b94c 100644
--- a/functions.cmake
+++ b/functions.cmake
@@ -192,7 +192,7 @@ endfunction()
function(vespa_add_executable TARGET)
cmake_parse_arguments(ARG
- ""
+ "TEST"
"INSTALL;OUTPUT_NAME"
"DEPENDS;AFTER;SOURCES"
${ARGN})
@@ -201,6 +201,16 @@ function(vespa_add_executable TARGET)
add_executable(${TARGET} ${ARG_SOURCES})
__add_dependencies_to_target()
+ # If this is a test executable, add it to the test target for this module
+ # If building of unit tests is not specified, exclude this target from the all target
+ if(ARG_TEST)
+ __add_test_target_to_module(${TARGET})
+
+ if(EXCLUDE_TESTS_FROM_ALL)
+ set_target_properties(${TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE)
+ endif()
+ endif()
+
if(ARG_INSTALL)
install(TARGETS ${TARGET} DESTINATION ${ARG_INSTALL})
endif()
@@ -344,13 +354,6 @@ function(vespa_add_test)
separate_arguments(ARG_COMMAND)
endif()
- # If there exists a target with the same name as the test, exclude the target from the "all" target
- # Instead, add it to the test target for this module
- if (TARGET ${ARG_NAME})
- set_target_properties(${ARG_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
- __add_test_target_to_module(${ARG_NAME})
- endif()
-
add_test(NAME ${ARG_NAME} COMMAND ${ARG_COMMAND} WORKING_DIRECTORY ${ARG_WORKING_DIRECTORY})
if(ARG_ENVIRONMENT)