Qt4Macros: Fix recently broken resource file parsing

Commit 4be67837 (read less from version headers into variables,
2012-08-19) switched from file(READ) and string(REGEX MATCHALL) to just
file(STRINGS) to extract the list of resource <file> entries.  However,
the latter extracts entire lines that match the regex, not just the part
that matches the regex, so the subsequent string(REGEX REPLACE) fails to
match and replace anything.  Return to the original parsing logic but
replace file(READ) with file(STRINGS) to load a minimal part of the file
before using string(REGEX MATCHALL) as before.
This commit is contained in:
Brad King 2012-08-22 08:33:12 -04:00
parent 4be6783711
commit 3553001bcc
1 changed files with 5 additions and 3 deletions

View File

@ -187,15 +187,17 @@ macro (QT4_ADD_RESOURCES outfiles )
if(EXISTS "${infile}")
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
file(STRINGS "${infile}" _RC_FILES REGEX "<file[^>]*>[^<]+")
foreach(_RC_FILE IN LISTS _RC_FILES)
string(REGEX REPLACE "^<file[^>]*>([^<]*)" "\\1" _RC_FILE "${_RC_FILE}")
file(STRINGS "${infile}" _RC_FILE_CONTENTS REGEX "<file[^>]*>[^<]+")
string(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
foreach(_RC_FILE ${_RC_FILES})
string(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
if(NOT IS_ABSOLUTE "${_RC_FILE}")
set(_RC_FILE "${rc_path}/${_RC_FILE}")
endif()
set(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
endforeach()
unset(_RC_FILES)
unset(_RC_FILE_CONTENTS)
# Since this cmake macro is doing the dependency scanning for these files,
# let's make a configured file and add it as a dependency so cmake is run
# again when dependencies need to be recomputed.