Qt4Macros: Added support for generated resource files
Using the QT4_ADD_RESOURCES() macro required the resource file to exist already for dependency scanning. This prevented the use of resource files that are generated by cmake because it needs the file before resolving the dependency. This patch adds support for generated resource files by not scanning the resource file for dependencies if it doesn't exist yet. The add_custom_command() to generate the resource file should add the dependencies on the files used by the resource file.
This commit is contained in:
parent
b639549c67
commit
9ce67d3001
|
@ -182,11 +182,13 @@ MACRO (QT4_ADD_RESOURCES outfiles )
|
|||
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
|
||||
GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
|
||||
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
|
||||
|
||||
SET(_RC_DEPENDS)
|
||||
IF(EXISTS "${infile}")
|
||||
# parse file for dependencies
|
||||
# all files are absolute paths or relative to the location of the qrc file
|
||||
FILE(READ "${infile}" _RC_FILE_CONTENTS)
|
||||
STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
|
||||
SET(_RC_DEPENDS)
|
||||
FOREACH(_RC_FILE ${_RC_FILES})
|
||||
STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
|
||||
IF(NOT IS_ABSOLUTE "${_RC_FILE}")
|
||||
|
@ -199,6 +201,12 @@ MACRO (QT4_ADD_RESOURCES outfiles )
|
|||
# again when dependencies need to be recomputed.
|
||||
QT4_MAKE_OUTPUT_FILE("${infile}" "" "qrc.depends" out_depends)
|
||||
CONFIGURE_FILE("${infile}" "${out_depends}" COPY_ONLY)
|
||||
ELSE(EXISTS "${infile}")
|
||||
# The .qrc file does not exist (yet). Let's add a dependency and hope
|
||||
# that it will be generated later
|
||||
SET(out_depends)
|
||||
ENDIF(EXISTS "${infile}")
|
||||
|
||||
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
|
||||
COMMAND ${QT_RCC_EXECUTABLE}
|
||||
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
|
||||
|
|
Loading…
Reference in New Issue