summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2026-02-15 12:23:05 +0100
committerSlávek Banko <slavek.banko@axis.cz>2026-03-01 14:54:46 +0100
commitbe8d196ab8f6e964175262eacd8ba11bb2f8e2a7 (patch)
tree77c54b31adf01c01c805119b9e845f648d0d5662
parent70811991ddbe46699c046ac2e715ae3494b97c60 (diff)
downloadtde-cmake-fix/install-icons.tar.gz
tde-cmake-fix/install-icons.zip
tde_file_glob: Added a function wrapping file( GLOB ... ) call.fix/install-icons
The function performs a reliability check of the result, because in some situations, the cause of which is not reasonably traceable, the call to file( GLOB ) is not reliable and requires retrying to return a reliable result. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--modules/TDEMacros.cmake73
1 files changed, 63 insertions, 10 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 377be1c..1457830 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -248,6 +248,59 @@ endmacro( tde_read_src_metadata )
################################################
#####
+##### tde_file_glob( <variable> [LIST_DIRECTORIES true|false] [RELATIVE <path>] [CONFIGURE_DEPENDS] <globbing-expressions>... )
+#####
+##### Equivalent for file( GLOB ... ) with reliability check of obtaining the result.
+#####
+
+function( tde_file_glob _variable )
+
+ # Initial findings
+ set( _glob_expr ${ARGV} )
+ file( GLOB _glob_0 ${_glob_expr} )
+ string( REPLACE ";" " " _glob_args "${_glob_expr}" )
+ if( "${_glob_0}" STREQUAL "" )
+ # This is not expected! Try again.
+ message( STATUS "Unexpected empty result: file( GLOB ${_glob_args} )" )
+ file( GLOB _glob_0 ${_glob_expr} )
+ endif()
+ list( SORT _glob_0 )
+
+ # Verification findings
+ file( GLOB _glob_1 ${_glob_expr} )
+ if( "${_glob_1}" STREQUAL "" )
+ message( STATUS "Unexpected empty result 1: file( GLOB ${_glob_args} )" )
+ file( GLOB _glob_1 ${_glob_expr} )
+ endif()
+ list( SORT _glob_1 )
+ if( NOT "${_glob_0}" STREQUAL "${_glob_1}" )
+ # Isn't it reliable? Try again.
+ file( GLOB _glob_2 ${_glob_expr} )
+ if( "${_glob_2}" STREQUAL "" )
+ message( STATUS "Unexpected empty result 2: file( GLOB ${_glob_args} )" )
+ file( GLOB _glob_2 ${_glob_expr} )
+ endif()
+ list( SORT _glob_2 )
+ if( NOT "${_glob_1}" STREQUAL "${_glob_2}" )
+ string( REPLACE ";" "\n " _glob_res0 "${_glob_0}" )
+ string( REPLACE ";" "\n " _glob_res1 "${_glob_1}" )
+ string( REPLACE ";" "\n " _glob_res2 "${_glob_2}" )
+ tde_message_fatal(
+ "file( GLOB ... ) seems to be quite unreliable!"
+ " Attempt 0:\n${_glob_res0}"
+ " Attempt 1:\n${_glob_res1}"
+ " Attempt 2:\n${_glob_res2}"
+ )
+ endif()
+ endif()
+
+ # Return result
+ set( ${_variable} ${_glob_1} PARENT_SCOPE )
+
+endfunction( tde_file_glob )
+
+################################################
+#####
##### finalization as a slave part
if( DEFINED MASTER_SOURCE_DIR )
@@ -279,7 +332,7 @@ macro( tde_install_icons )
foreach( _icon ${_icons} )
unset( _theme ) # clearing
- file(GLOB _icon_files *-${_icon}.png *-${_icon}.mng *-${_icon}.svg* *-${_icon}.xpm )
+ tde_file_glob( _icon_files *-${_icon}.png *-${_icon}.mng *-${_icon}.svg* *-${_icon}.xpm )
foreach( _icon_file ${_icon_files} )
# FIXME need a review
string( REGEX MATCH "^.*/([a-zA-Z][a-zA-Z])([0-9a-zA-Z]+)\\-([a-z]+)\\-([^/]+)$" _dummy "${_icon_file}" )
@@ -857,7 +910,7 @@ endmacro( tde_install_libtool_file )
##### tde_install_export / tde_import
function( tde_install_export )
- file( GLOB export_files ${CMAKE_CURRENT_BINARY_DIR}/export-*.cmake )
+ tde_file_glob( export_files ${CMAKE_CURRENT_BINARY_DIR}/export-*.cmake )
list( SORT export_files )
set( mode "WRITE" )
@@ -1652,7 +1705,7 @@ macro( tde_add_check_executable _arg_target )
# try to autodetect sources
if( NOT _sources )
- file( GLOB _sources "${_target}.cpp" "${_target}.cxx" "${_target}.c" )
+ tde_file_glob( _sources "${_target}.cpp" "${_target}.cxx" "${_target}.c" )
if( NOT _sources )
message( FATAL_ERROR "\nNo sources found for test executable \"${_target}\"." )
endif( )
@@ -1908,7 +1961,7 @@ macro( tde_create_translation )
# if no file specified, include all *.po files
if( NOT _srcs )
- file( GLOB _srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.po )
+ tde_file_glob( _srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.po )
endif( )
if( NOT _srcs )
tde_message_fatal( "no source files" )
@@ -2186,7 +2239,7 @@ macro( tde_create_translated_desktop )
# are there any translations available?
unset( _translations )
if( EXISTS "${_po_dir}" AND IS_DIRECTORY "${_po_dir}" )
- file( GLOB _translations RELATIVE "${_po_dir}" "${_po_dir}/*.po" )
+ tde_file_glob( _translations RELATIVE "${_po_dir}" "${_po_dir}/*.po" )
endif( )
# prepare a full name for the target
@@ -2344,7 +2397,7 @@ function( tde_add_project_docs )
else()
string( REGEX REPLACE "^[^/]*/(.*)" "\\1" _doc_dest "${_dir}/${PROJECT_NAME}" )
endif()
- file( GLOB _doc_files RELATIVE ${DOCS_SOURCE_DIR}/${_dir} ${DOCS_SOURCE_DIR}/${_dir}/*.docbook )
+ tde_file_glob( _doc_files RELATIVE ${DOCS_SOURCE_DIR}/${_dir} ${DOCS_SOURCE_DIR}/${_dir}/*.docbook )
if( _doc_files )
list( FIND _doc_files "index.docbook" _find_index )
if( -1 EQUAL _find_index )
@@ -2359,9 +2412,9 @@ function( tde_add_project_docs )
DESTINATION ${_doc_dest}
)
else()
- file( GLOB _html_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${DOCS_SOURCE_DIR}/${_dir}/*.html )
+ tde_file_glob( _html_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${DOCS_SOURCE_DIR}/${_dir}/*.html )
if( _html_files )
- file( GLOB _htmldoc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ tde_file_glob( _htmldoc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${DOCS_SOURCE_DIR}/${_dir}/*.css
${DOCS_SOURCE_DIR}/${_dir}/*.gif
${DOCS_SOURCE_DIR}/${_dir}/*.jpg
@@ -2531,7 +2584,7 @@ macro( tde_create_handbook )
# if no file specified, include all docbooks, stylesheets and images
if( NOT _srcs )
- file( GLOB _srcs
+ tde_file_glob( _srcs
${_source_basedir}/*.docbook
${_source_basedir}/*.css
${_source_basedir}/*.gif
@@ -2808,7 +2861,7 @@ endmacro( tde_conditional_add_subdirectory )
##### tde_auto_add_subdirectories
macro( tde_auto_add_subdirectories )
- file( GLOB _dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} * )
+ tde_file_glob( _dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} * )
foreach( _dir ${_dirs} )
if( IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_dir} )
if( NOT ${_dir} STREQUAL ".svn" AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt )