From b9d0276c0f605c950cc739eafbdad9cc3f4ece6a Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Mon, 16 Nov 2020 16:33:34 +0000 Subject: Fix updating of apptemplate tars With this MR cmake gets rerun when the dirs/subdirs of the template change. And by setting the `DEPENDS` property of the tar command to this list of the dirs/subdirs of the template we ensure that the command gets executed whenever the files change. --- kde-modules/KDEPackageAppTemplates.cmake | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'kde-modules/KDEPackageAppTemplates.cmake') diff --git a/kde-modules/KDEPackageAppTemplates.cmake b/kde-modules/KDEPackageAppTemplates.cmake index 54fb6fa6..37e989ee 100644 --- a/kde-modules/KDEPackageAppTemplates.cmake +++ b/kde-modules/KDEPackageAppTemplates.cmake @@ -84,32 +84,29 @@ function(kde_package_app_templates) endif() foreach(_templateName ${ARG_TEMPLATES}) - get_filename_component(_tmp_file ${_templateName} ABSOLUTE) get_filename_component(_baseName ${_tmp_file} NAME_WE) set(_template ${CMAKE_CURRENT_BINARY_DIR}/${_baseName}.tar.bz2) - file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*") - set(_deps) - foreach(_file ${_files}) - get_filename_component(_fileName ${_file} NAME) - string(COMPARE NOTEQUAL ${_fileName} .kdev_ignore _v1) - string(REGEX MATCH "\\.svn" _v2 ${_fileName}) - if(WIN32) - string(REGEX MATCH "_svn" _v3 ${_fileName}) - else(WIN32) - set(_v3 FALSE) - endif() - if (_v1 AND NOT _v2 AND NOT _v3) - set(_deps ${_deps} ${_file}) - endif () - endforeach() - + # CONFIGURE_DEPENDS is only available for cmake >= 3.12 + if(NOT CMAKE_VERSION VERSION_LESS "3.12.0") + # also enlist directories as deps to catch file removals + file(GLOB_RECURSE _subdirs_entries LIST_DIRECTORIES true CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*") + else() + file(GLOB_RECURSE _subdirs_entries LIST_DIRECTORIES true "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*") + # custom code to implement CONFIGURE_DEPENDS + foreach(_direntry ${_subdirs_entries}) + if(IS_DIRECTORY ${_direntry}) + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_direntry}) + endif() + endforeach() + endif() add_custom_target(${_baseName} ALL DEPENDS ${_template}) add_custom_command(OUTPUT ${_template} COMMAND ${CMAKE_COMMAND} -E tar "cvfj" ${_template} . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} + DEPENDS ${_subdirs_entries} ) -- cgit v1.2.1