Qt: Distribute shaders as zipped archives on supported builds

This commit is contained in:
Vicki Pfau 2023-07-16 01:45:04 -07:00
parent c49050fe65
commit 51d5f4bfd1
3 changed files with 18 additions and 2 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.3)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/src/platform/cmake/")
if(POLICY CMP0025)

View File

@ -327,7 +327,19 @@ if(NOT DEFINED DATADIR)
endif()
endif()
if(BUILD_GL OR BUILD_GLES2 OR BUILD_EPOXY)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt)
if(NOT USE_LIBZIP AND NOT USE_MINIZIP)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt)
else()
file(GLOB SHADERS ${CMAKE_SOURCE_DIR}/res/shaders/*.shader)
message(STATUS ${SHADERS})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/shaders)
foreach(SHADER_DIR ${SHADERS})
get_filename_component(SHADER ${SHADER_DIR} NAME)
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER}" COMMAND "${CMAKE_COMMAND}" -E tar cf "${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER}" --format=zip . WORKING_DIRECTORY "${SHADER_DIR}")
add_custom_target("${SHADER}" ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER}" DESTINATION ${DATADIR}/shaders COMPONENT ${BINARY_NAME}-qt)
endforeach()
endif()
endif()
if(ENABLE_SCRIPTING AND USE_LUA)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/scripts DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt)

View File

@ -63,7 +63,11 @@ void ShaderSelector::clear() {
void ShaderSelector::selectShader() {
QDir path(GBAApp::dataDir());
path.cd(QLatin1String("shaders"));
#if !defined(USE_LIBZIP) && !defined(USE_MINIZIP)
QString name = GBAApp::app()->getOpenDirectoryName(this, tr("Load shader"), path.absolutePath());
#else
QString name = GBAApp::app()->getOpenFileName(this, tr("Load shader"), "mGBA Shaders (*.shader)", path.absolutePath());
#endif
if (!name.isNull()) {
loadShader(name);
refreshShaders();