Qt: Move resources out of exe into rcc file
This commit is contained in:
parent
8c0af03448
commit
0d3e674500
|
@ -18,6 +18,7 @@
|
|||
<QtToolOutDir>$(IntDir)</QtToolOutDir>
|
||||
<QtMocOutPrefix>$(QtToolOutDir)moc_</QtMocOutPrefix>
|
||||
<QtTsOutDir>$(BinaryOutputDir)translations\</QtTsOutDir>
|
||||
<QtRccOutDir>$(BinaryOutputDir)resources\</QtRccOutDir>
|
||||
<QtDebugSuffix>d</QtDebugSuffix>
|
||||
<QtLibSuffix Condition="$(Configuration.Contains(Debug))">$(QtDebugSuffix)</QtLibSuffix>
|
||||
<QtPluginFolder>QtPlugins</QtPluginFolder>
|
||||
|
@ -41,18 +42,18 @@
|
|||
<ResFiles Include="$(MSBuildProjectDirectory)\**\*.qrc" />
|
||||
</ItemGroup>
|
||||
<Target Name="QtResource"
|
||||
BeforeTargets="ClCompile"
|
||||
AfterTargets="Build"
|
||||
Inputs="@(ResFiles)"
|
||||
Condition="'@(QtResource)'!=''"
|
||||
Outputs="@(ResFiles->'$(QtToolOutDir)qrc_%(Filename).cpp')">
|
||||
Outputs="@(ResFiles->'$(QtRccOutDir)%(Filename).rcc')">
|
||||
<Message Text="rcc %(ResFiles.Filename)" Importance="High" />
|
||||
<Error Condition="!$(DSQTDIRValid)" Text="Qt directory non-existent (download/extract the zip)" />
|
||||
<MakeDir Directories="$(QtToolOutDir)" />
|
||||
<Exec Command=""$(QtHostBinDir)rcc.exe" "%(ResFiles.FullPath)" -o "$(QtToolOutDir)qrc_%(ResFiles.Filename).cpp"" />
|
||||
<MakeDir Directories="$(QtRccOutDir)" />
|
||||
<Exec Command=""$(QtHostBinDir)rcc.exe" -binary -no-compress "%(ResFiles.FullPath)" -o "$(QtRccOutDir)%(ResFiles.Filename).rcc"" />
|
||||
</Target>
|
||||
|
||||
<Target Name="QtResourceClean">
|
||||
<Delete Files="@(ResFiles->'$(QtToolOutDir)qrc_%(Filename).cpp')" />
|
||||
<Delete Files="@(ResFiles->'$(QtRccOutDir)%(Filename).rcc')" />
|
||||
</Target>
|
||||
|
||||
<!--Passes all .ui files to uic and puts output in the build directory-->
|
||||
|
|
|
@ -3,11 +3,9 @@ find_package(Qt6 6.7.2 COMPONENTS Core Gui Widgets LinguistTools REQUIRED)
|
|||
include(CopyBaseTranslations)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
set(SRCS
|
||||
resources/resources.qrc
|
||||
aboutdialog.cpp
|
||||
aboutdialog.h
|
||||
aboutdialog.ui
|
||||
|
@ -253,6 +251,20 @@ elseif(APPLE)
|
|||
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
endif()
|
||||
|
||||
# Compile qrc to a binary file.
|
||||
if(NOT APPLE)
|
||||
set(RCC_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/duckstation-qt.rcc")
|
||||
qt_add_binary_resources(duckstation-qt-rcc resources/duckstation-qt.qrc DESTINATION ${RCC_FILE} OPTIONS -no-compress)
|
||||
add_dependencies(duckstation-qt duckstation-qt-rcc)
|
||||
else()
|
||||
set(RCC_FILE "${CMAKE_CURRENT_BINARY_DIR}/duckstation-qt.rcc")
|
||||
qt_add_binary_resources(duckstation-qt-rcc resources/duckstation-qt.qrc DESTINATION ${RCC_FILE} OPTIONS -no-compress)
|
||||
add_dependencies(duckstation-qt duckstation-qt-rcc)
|
||||
target_sources(duckstation-qt PRIVATE ${RCC_FILE})
|
||||
set_source_files_properties(${RCC_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
endif()
|
||||
|
||||
|
||||
# Translation setup.
|
||||
qt_add_lrelease(duckstation-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
|
||||
if(NOT APPLE)
|
||||
|
|
|
@ -211,7 +211,7 @@
|
|||
</QtUi>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtResource Include="resources\resources.qrc">
|
||||
<QtResource Include="resources\duckstation-qt.qrc">
|
||||
<FileType>Document</FileType>
|
||||
</QtResource>
|
||||
</ItemGroup>
|
||||
|
@ -259,7 +259,6 @@
|
|||
<ClCompile Include="$(IntDir)moc_qtprogresscallback.cpp" />
|
||||
<ClCompile Include="$(IntDir)moc_settingswindow.cpp" />
|
||||
<ClCompile Include="$(IntDir)moc_setupwizarddialog.cpp" />
|
||||
<ClCompile Include="$(IntDir)qrc_resources.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="qt5.natvis" />
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
<ClCompile Include="advancedsettingswidget.cpp" />
|
||||
<ClCompile Include="aboutdialog.cpp" />
|
||||
<ClCompile Include="memorycardsettingswidget.cpp" />
|
||||
<ClCompile Include="$(IntDir)qrc_resources.cpp" />
|
||||
<ClCompile Include="inputbindingdialog.cpp" />
|
||||
<ClCompile Include="gamelistmodel.cpp" />
|
||||
<ClCompile Include="autoupdaterdialog.cpp" />
|
||||
|
@ -300,7 +299,7 @@
|
|||
<Image Include="duckstation-qt.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtResource Include="resources\resources.qrc">
|
||||
<QtResource Include="resources\duckstation-qt.qrc">
|
||||
<Filter>resources</Filter>
|
||||
</QtResource>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -479,10 +479,12 @@ bool QtHost::SetCriticalFolders()
|
|||
CrashHandler::SetWriteDirectory(EmuFolders::DataRoot);
|
||||
|
||||
// the resources directory should exist, bail out if not
|
||||
if (!FileSystem::DirectoryExists(EmuFolders::Resources.c_str()))
|
||||
const std::string rcc_path = Path::Combine(EmuFolders::Resources, "duckstation-qt.rcc");
|
||||
if (!FileSystem::DirectoryExists(EmuFolders::Resources.c_str()) || !FileSystem::FileExists(rcc_path.c_str()) ||
|
||||
!QResource::registerResource(QString::fromStdString(rcc_path)))
|
||||
{
|
||||
QMessageBox::critical(nullptr, QStringLiteral("Error"),
|
||||
QStringLiteral("Resources directory is missing, your installation is incomplete."));
|
||||
QStringLiteral("Resources are missing, your installation is incomplete."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2415,7 +2417,7 @@ bool QtHost::ParseCommandLineParametersAndInitializeConfig(QApplication& app,
|
|||
}
|
||||
|
||||
// To do anything useful, we need the config initialized.
|
||||
if (!QtHost::InitializeConfig(std::move(settings_filename)))
|
||||
if (!InitializeConfig(std::move(settings_filename)))
|
||||
{
|
||||
// NOTE: No point translating this, because no config means the language won't be loaded anyway.
|
||||
QMessageBox::critical(nullptr, QStringLiteral("Error"), QStringLiteral("Failed to initialize config."));
|
||||
|
|
Loading…
Reference in New Issue