forked from qt-creator/qt-creator
CMake build: Add a qtc_glob_resources function
This is the CMake equivalent of "RESOURCES = $$files()" from qmake. Use it in StudioWelcome for the Qml resources. Change-Id: I2f495e2c4bad9f0bb488dee7e8966e31acb51b5a Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -1124,3 +1124,16 @@ function(finalize_qtc_gtest test_name)
|
||||
finalize_test_setup(${test})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# This is the CMake equivalent of "RESOURCES = $$files()" from qmake
|
||||
function(qtc_glob_resources)
|
||||
cmake_parse_arguments(_arg "" "QRC_FILE;ROOT;GLOB" "" ${ARGN})
|
||||
|
||||
file(GLOB_RECURSE fileList RELATIVE "${_arg_ROOT}" "${_arg_ROOT}/${_arg_GLOB}")
|
||||
set(qrcData "<RCC><qresource>\n")
|
||||
foreach(file IN LISTS fileList)
|
||||
string(APPEND qrcData " <file alias=\"${file}\">${_arg_ROOT}/${file}</file>\n")
|
||||
endforeach()
|
||||
string(APPEND qrcData "</qresource></RCC>")
|
||||
file(WRITE "${_arg_QRC_FILE}" "${qrcData}")
|
||||
endfunction()
|
||||
|
@@ -1,3 +1,11 @@
|
||||
set(qmlQrcFile "${CMAKE_CURRENT_BINARY_DIR}/StudioWelcome_qml.qrc")
|
||||
|
||||
qtc_glob_resources(
|
||||
QRC_FILE "${qmlQrcFile}"
|
||||
ROOT "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
GLOB "qml/*.*"
|
||||
)
|
||||
|
||||
add_qtc_plugin(StudioWelcome
|
||||
DEPENDS Qt5::QuickWidgets
|
||||
PLUGIN_DEPENDS Core ProjectExplorer QtSupport
|
||||
@@ -6,7 +14,7 @@ add_qtc_plugin(StudioWelcome
|
||||
studiowelcomeplugin.cpp studiowelcomeplugin.h
|
||||
studiowelcome_global.h
|
||||
studiowelcome.qrc
|
||||
studiowelcome_qml.qrc
|
||||
${qmlQrcFile}
|
||||
"${PROJECT_SOURCE_DIR}/src/share/3rdparty/studiofonts/studiofonts.qrc"
|
||||
EXTRA_TRANSLATIONS
|
||||
qml
|
||||
|
@@ -1,6 +0,0 @@
|
||||
<!-- This file is the CMake equivalent of "RESOURCES = $$files(qml/*)" in studiowelcome.pro -->
|
||||
<RCC>
|
||||
<qresource>
|
||||
<file>qml/</file>
|
||||
</qresource>
|
||||
</RCC>
|
Reference in New Issue
Block a user