aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
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-08-13 08:04:33 +0000
commit85d5ffd288a652481c801799a0895f2fcb5de323 (patch)
tree6ace44745e73b4c81196aaa06ba53a5251bebcbb /cmake
parentd14bdceab76e81c3807e4b75c613276f9f5369b8 (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>
Diffstat (limited to 'cmake')
-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()