summaryrefslogtreecommitdiffstats
path: root/src/corelib/Qt5CoreMacros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/Qt5CoreMacros.cmake')
-rw-r--r--src/corelib/Qt5CoreMacros.cmake104
1 files changed, 78 insertions, 26 deletions
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 02f1d313d7..249138e073 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -185,6 +185,77 @@ function(QT5_WRAP_CPP outfiles )
endfunction()
+
+# _qt5_parse_qrc_file(infile _out_depends _rc_depends)
+# internal
+
+function(_QT5_PARSE_QRC_FILE infile _out_depends _rc_depends)
+ get_filename_component(rc_path ${infile} PATH)
+
+ 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}")
+ 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()
+ # 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.
+ qt5_make_output_file("${infile}" "" "qrc.depends" out_depends)
+ configure_file("${infile}" "${out_depends}" COPYONLY)
+ else()
+ # The .qrc file does not exist (yet). Let's add a dependency and hope
+ # that it will be generated later
+ set(out_depends)
+ endif()
+
+ set(${_out_depends} ${out_depends} PARENT_SCOPE)
+ set(${_rc_depends} ${RC_DEPENDS} PARENT_SCOPE)
+endfunction()
+
+
+# qt5_add_binary_resources(target inputfiles ... )
+
+function(QT5_ADD_BINARY_RESOURCES target )
+
+ set(options)
+ set(oneValueArgs DESTINATION)
+ set(multiValueArgs OPTIONS)
+
+ cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
+ set(rcc_options ${_RCC_OPTIONS})
+ set(rcc_destination ${_RCC_DESTINATION})
+
+ if(NOT rcc_destination)
+ set(rcc_destination ${CMAKE_CURRENT_BINARY_DIR}/${target}.rcc)
+ endif()
+
+ foreach(it ${rcc_files})
+ get_filename_component(infile ${it} ABSOLUTE)
+
+ _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
+ set(infiles ${infiles} ${infile})
+ set(out_depends ${out_depends} ${_out_depends})
+ set(rc_depends ${rc_depends} ${_rc_depends})
+ endforeach()
+
+ add_custom_command(OUTPUT ${rcc_destination}
+ COMMAND ${Qt5Core_RCC_EXECUTABLE}
+ ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles}
+ DEPENDS ${rc_depends} ${out_depends} VERBATIM)
+
+ add_custom_target(${target} ALL DEPENDS ${rcc_destination})
+endfunction()
+
+
# qt5_add_resources(outfiles inputfile ... )
function(QT5_ADD_RESOURCES outfiles )
@@ -198,41 +269,22 @@ function(QT5_ADD_RESOURCES outfiles )
set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
set(rcc_options ${_RCC_OPTIONS})
+ if(${rcc_options} MATCHES "-binary")
+ message(WARNING "Use qt5_add_binary_resources for binary option")
+ endif()
+
foreach(it ${rcc_files})
get_filename_component(outfilename ${it} NAME_WE)
get_filename_component(infile ${it} ABSOLUTE)
- get_filename_component(rc_path ${infile} PATH)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp)
- 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}")
- 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()
- # 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.
- qt5_make_output_file("${infile}" "" "qrc.depends" out_depends)
- configure_file("${infile}" "${out_depends}" COPYONLY)
- else()
- # The .qrc file does not exist (yet). Let's add a dependency and hope
- # that it will be generated later
- set(out_depends)
- endif()
+ _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
add_custom_command(OUTPUT ${outfile}
COMMAND ${Qt5Core_RCC_EXECUTABLE}
- ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
+ ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
- DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
+ DEPENDS ${_rc_depends} "${out_depends}" VERBATIM)
list(APPEND ${outfiles} ${outfile})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)