summaryrefslogtreecommitdiffstats
path: root/functions.cmake
diff options
context:
space:
mode:
authorVegard Sjonfjell <vegard@yahoo-inc.com>2016-06-17 13:49:59 +0200
committerVegard Sjonfjell <vegard@yahoo-inc.com>2016-06-17 13:49:59 +0200
commit27cf51bedd200f9cee8b42d665466f870c4e1be0 (patch)
tree863ce0011d71e5aa5b6773eead221be282309562 /functions.cmake
parent2eceb7f4e457ffbca92403b444eaf3b07d185971 (diff)
Libraries can also be test targets
Diffstat (limited to 'functions.cmake')
-rw-r--r--functions.cmake26
1 files changed, 16 insertions, 10 deletions
diff --git a/functions.cmake b/functions.cmake
index 46b8083b94c..8047a170320 100644
--- a/functions.cmake
+++ b/functions.cmake
@@ -151,7 +151,7 @@ endfunction()
function(vespa_add_library TARGET)
cmake_parse_arguments(ARG
- "STATIC;OBJECT;INTERFACE"
+ "STATIC;OBJECT;INTERFACE;TEST"
"INSTALL;OUTPUT_NAME"
"DEPENDS;AFTER;SOURCES"
${ARGN})
@@ -178,6 +178,8 @@ function(vespa_add_library TARGET)
add_library(${TARGET} ${LINKAGE} ${LIBRARY_TYPE} ${SOURCE_FILES})
__add_dependencies_to_target()
+ __handle_test_targets()
+
if(ARG_INSTALL)
install(TARGETS ${TARGET} DESTINATION ${ARG_INSTALL})
endif()
@@ -201,15 +203,7 @@ 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()
+ __handle_test_targets()
if(ARG_INSTALL)
install(TARGETS ${TARGET} DESTINATION ${ARG_INSTALL})
@@ -439,6 +433,18 @@ function(__add_test_target_to_module TARGET)
set_property(GLOBAL APPEND PROPERTY MODULE_${MODULE_NAME}_TEST_TARGETS ${TARGET})
endfunction()
+function(__handle_test_targets)
+ # 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()
+endfunction()
+
function(__create_module_targets PROPERTY_POSTFIX TARGET_POSTFIX)
get_property(VESPA_MODULES GLOBAL PROPERTY VESPA_MODULES)
set(OUTPUT_ALL_TARGET "all_${TARGET_POSTFIX}s")