summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-08-10 12:08:53 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-10-15 18:22:48 +0200
commit20522393fee121c684fae3b03c5e8dafd4e820b6 (patch)
treea5bf519ae7c60047dd960406bdcd6e0a10baab91
parent79fbc2b454a2a2da5c91adb2e4cb0b25636753a2 (diff)
Test widget only if there are test materials
This checks if there is a target with a TEST LABELS property which would indicate that there is something to pack in the test widget, else it would generate an empty and useless test widget. Change-Id: If2a3eb32762f5d62877ea19faed70d4b6e68a0a0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--cmake/cmake.d/03-macros.cmake18
1 files changed, 13 insertions, 5 deletions
diff --git a/cmake/cmake.d/03-macros.cmake b/cmake/cmake.d/03-macros.cmake
index c1ed23c..efe3128 100644
--- a/cmake/cmake.d/03-macros.cmake
+++ b/cmake/cmake.d/03-macros.cmake
@@ -124,6 +124,15 @@ macro(PROJECT_TARGET_ADD TARGET_NAME)
set(TARGET_NAME ${TARGET_NAME})
endmacro(PROJECT_TARGET_ADD)
+macro(PROJECT_HAS_TESTS)
+ foreach(T ${PROJECT_TARGETS})
+ get_target_property(TL ${T} "LABELS")
+ if(TL AND "${TL}" MATCHES "^TEST-")
+ set(HAS_TESTS TRUE)
+ endif()
+ endforeach()
+endmacro()
+
macro(PROJECT_PKGDEP_ADD PKG_NAME)
set_property(GLOBAL APPEND PROPERTY PROJECT_PKG_DEPS ${PKG_NAME})
endmacro(PROJECT_PKGDEP_ADD)
@@ -300,14 +309,12 @@ macro(project_targets_populate)
set(PACKAGE_TEST_DATADIR ${PROJECT_PKG_TEST_DIR}/${DATADIR})
if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "RELEASE")
- add_custom_command(OUTPUT ${PACKAGE_BINDIR} ${PACKAGE_ETCDIR} ${PACKAGE_LIBDIR} ${PACKAGE_HTTPDIR} ${PACKAGE_DATADIR} ${PACKAGE_TEST_BINDIR} ${PACKAGE_TEST_ETCDIR} ${PACKAGE_TEST_LIBDIR} ${PACKAGE_TEST_HTTPDIR} ${PACKAGE_TEST_DATADIR}
+ add_custom_target(populate
COMMAND mkdir -p ${PACKAGE_BINDIR} ${PACKAGE_ETCDIR} ${PACKAGE_LIBDIR} ${PACKAGE_HTTPDIR} ${PACKAGE_DATADIR}
COMMAND mkdir -p ${PACKAGE_TEST_BINDIR} ${PACKAGE_TEST_ETCDIR} ${PACKAGE_TEST_LIBDIR} ${PACKAGE_TEST_HTTPDIR} ${PACKAGE_TEST_DATADIR})
- add_custom_target(populate DEPENDS ${PACKAGE_BINDIR} ${PACKAGE_ETCDIR} ${PACKAGE_LIBDIR} ${PACKAGE_HTTPDIR} ${PACKAGE_DATADIR} ${PACKAGE_TEST_BINDIR} ${PACKAGE_TEST_ETCDIR} ${PACKAGE_TEST_LIBDIR} ${PACKAGE_TEST_HTTPDIR} ${PACKAGE_TEST_DATADIR})
else()
- add_custom_command(OUTPUT ${PACKAGE_BINDIR} ${PACKAGE_ETCDIR} ${PACKAGE_LIBDIR} ${PACKAGE_HTTPDIR} ${PACKAGE_DATADIR}
+ add_custom_target(populate
COMMAND mkdir -p ${PACKAGE_BINDIR} ${PACKAGE_ETCDIR} ${PACKAGE_LIBDIR} ${PACKAGE_HTTPDIR} ${PACKAGE_DATADIR})
- add_custom_target(populate DEPENDS ${PACKAGE_BINDIR} ${PACKAGE_ETCDIR} ${PACKAGE_LIBDIR} ${PACKAGE_HTTPDIR} ${PACKAGE_DATADIR})
endif()
# Dirty trick to define a default INSTALL command for app-templates handled
@@ -546,7 +553,8 @@ macro(wgt_package_build)
COMMAND ${packCMDTest}
)
- if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "RELEASE")
+ PROJECT_HAS_TESTS()
+ if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "RELEASE" AND HAS_TESTS)
add_custom_target(widget DEPENDS ${WGT_NAME}.wgt ${WGT_NAME}-test.wgt)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/${WGT_NAME}-test.wgt")
else()