mirror of https://github.com/qt/qtbase.git
Add support for big resources with CMake
Task-number: QTBUG-55680 Change-Id: I09570a4e959ffd0e6d378bc315b13d57baaa82e8 Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
This commit is contained in:
parent
44b6757fe5
commit
cdccd0222b
|
@ -293,6 +293,49 @@ function(QT5_ADD_RESOURCES outfiles )
|
|||
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# qt5_add_big_resources(outfiles inputfile ... )
|
||||
|
||||
function(QT5_ADD_BIG_RESOURCES outfiles )
|
||||
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs OPTIONS)
|
||||
|
||||
cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
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)
|
||||
set(tmpoutfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}tmp.cpp)
|
||||
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.o)
|
||||
|
||||
_QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
|
||||
set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
|
||||
add_custom_command(OUTPUT ${tmpoutfile}
|
||||
COMMAND ${Qt5Core_RCC_EXECUTABLE} ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile}
|
||||
DEPENDS ${infile} ${_rc_depends} "${out_depends}" VERBATIM)
|
||||
set_source_files_properties(${tmpoutfile} PROPERTIES SKIP_AUTOMOC ON)
|
||||
set_source_files_properties(${tmpoutfile} PROPERTIES SKIP_AUTOUIC ON)
|
||||
add_custom_target(big_resources_${outfilename} ALL DEPENDS ${tmpoutfile})
|
||||
add_library(rcc_object_${outfilename} OBJECT ${tmpoutfile})
|
||||
add_dependencies(rcc_object_${outfilename} big_resources_${outfilename})
|
||||
add_custom_command(OUTPUT ${outfile}
|
||||
COMMAND ${Qt5Core_RCC_EXECUTABLE}
|
||||
ARGS ${rcc_options} --name ${outfilename} --pass 2 --temp $<TARGET_OBJECTS:rcc_object_${outfilename}> --output ${outfile} ${infile}
|
||||
DEPENDS rcc_object_${outfilename}
|
||||
VERBATIM)
|
||||
list(APPEND ${outfiles} ${outfile})
|
||||
endforeach()
|
||||
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
|
||||
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
|
||||
|
|
|
@ -146,6 +146,7 @@ endif()
|
|||
|
||||
expect_pass(test_interface_link_libraries)
|
||||
expect_pass(test_moc_macro_target)
|
||||
expect_pass(test_add_big_resource)
|
||||
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.8)
|
||||
# With earlier CMake versions, this test would simply run moc multiple times and lead to:
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(test_add_big_resource)
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
|
||||
qt5_wrap_cpp(moc_files myobject.h)
|
||||
|
||||
qt5_add_big_resources(rcc_files "test_add_big_resource.qrc" "test_add_big_resource2.qrc")
|
||||
|
||||
add_executable(myobject myobject.cpp ${moc_files} ${rcc_files})
|
||||
target_link_libraries(myobject ${Qt5Core_LIBRARIES})
|
|
@ -0,0 +1,44 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "myobject.h"
|
||||
|
||||
MyObject::MyObject(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
emit someSignal();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MyObject myObject;
|
||||
// Compile error if the resource file was not created.
|
||||
Q_INIT_RESOURCE(test_add_big_resource);
|
||||
Q_INIT_RESOURCE(test_add_big_resource2);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MYOBJECT_H
|
||||
#define MYOBJECT_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class MyObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyObject(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void someSignal();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1 @@
|
|||
Ken sent me.
|
|
@ -0,0 +1 @@
|
|||
Ken sent me.
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>resource_file.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>resource_file2.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
Reference in New Issue