From 27cf51bedd200f9cee8b42d665466f870c4e1be0 Mon Sep 17 00:00:00 2001 From: Vegard Sjonfjell Date: Fri, 17 Jun 2016 13:49:59 +0200 Subject: Libraries can also be test targets --- functions.cmake | 26 ++++++++++++++++---------- 1 file 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") -- cgit v1.2.3