build(install): rescan GLOB files on rebuild

This commit is contained in:
Jakub Łuczyński 2021-10-17 14:46:44 +02:00
parent 389a898586
commit 6b0a2e6996
2 changed files with 28 additions and 10 deletions

View File

@ -154,3 +154,25 @@ function(install_helper)
${RENAME})
endif()
endfunction()
# Without CONFIGURE_DEPENDS globbing reuses cached file tree on rebuild.
# For example it will ignore new files.
# CONFIGURE_DEPENDS was introduced in 3.12
function(glob_wrapper outvar)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
file(GLOB ${outvar} ${ARGN})
else()
file(GLOB ${outvar} CONFIGURE_DEPENDS ${ARGN})
endif()
set(${outvar} ${${outvar}} PARENT_SCOPE)
endfunction()
function(globrecurse_wrapper outvar root)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
file(GLOB_RECURSE ${outvar} RELATIVE ${root} ${ARGN})
else()
file(GLOB_RECURSE ${outvar} CONFIGURE_DEPENDS RELATIVE ${root} ${ARGN})
endif()
set(${outvar} ${${outvar}} PARENT_SCOPE)
endfunction()

View File

@ -21,12 +21,12 @@ add_custom_command(OUTPUT ${GENERATED_SYN_VIM}
${FUNCS_DATA}
)
file(GLOB PACKAGES ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*)
glob_wrapper(PACKAGES ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*)
set(GENERATED_PACKAGE_TAGS)
foreach(PACKAGE ${PACKAGES})
get_filename_component(PACKNAME ${PACKAGE} NAME)
file(GLOB "${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt)
glob_wrapper("${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt)
if(${PACKNAME}_DOC_FILES)
file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME})
add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
@ -54,7 +54,7 @@ foreach(PACKAGE ${PACKAGES})
endif()
endforeach()
file(GLOB DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
glob_wrapper(DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
set(BUILDDOCFILES)
foreach(DF ${DOCFILES})
@ -114,9 +114,7 @@ if(NOT APPLE)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
endif()
file(GLOB_RECURSE RUNTIME_PROGRAMS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.awk *.sh *.bat)
globrecurse_wrapper(RUNTIME_PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR} *.awk *.sh *.bat)
foreach(PROG ${RUNTIME_PROGRAMS})
get_filename_component(BASEDIR ${PROG} PATH)
@ -124,10 +122,8 @@ foreach(PROG ${RUNTIME_PROGRAMS})
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
endforeach()
file(GLOB_RECURSE RUNTIME_FILES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
rgb.txt
*.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
globrecurse_wrapper(RUNTIME_FILES ${CMAKE_CURRENT_SOURCE_DIR}
rgb.txt *.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
foreach(F ${RUNTIME_FILES})
get_filename_component(BASEDIR ${F} PATH)