summaryrefslogtreecommitdiffstats
path: root/functions.cmake
diff options
context:
space:
mode:
authorVegard Sjonfjell <vegard@yahoo-inc.com>2016-06-16 14:18:24 +0200
committerVegard Sjonfjell <vegard@yahoo-inc.com>2016-06-16 14:18:24 +0200
commit63f4017a6f42955a182f0a1a33cfe6449b090704 (patch)
treecf1589da036146f924847a5d6bb2aa0a785da75a /functions.cmake
parenta46f6dcc87f07996fbd32ecc07b4253bd563b840 (diff)
Do not build tests as part of all target if EXCLUDE_TESTS_FROM_ALL is set
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)