Qt: Set sensible shader dir

This commit is contained in:
Jeffrey Pfau 2015-11-23 20:20:57 -08:00
parent e53cc7060c
commit aa34b5bdd2
2 changed files with 29 additions and 14 deletions

View File

@ -60,7 +60,7 @@ endif()
get_target_property(QT_TYPE Qt5::Core TYPE)
if(QT_TYPE STREQUAL STATIC_LIBRARY)
set(QT_STATIC ON)
add_definitions(-DQT_STATIC)
list(APPEND QT_DEFINES QT_STATIC)
endif()
set(SOURCE_FILES
@ -126,6 +126,7 @@ if(BUILD_SDL)
list(APPEND AUDIO_SRC AudioProcessorSDL.cpp)
endif()
set(QT_DEFINES)
if(Qt5Multimedia_FOUND)
list(APPEND AUDIO_SRC
AudioProcessorQt.cpp
@ -134,7 +135,7 @@ if(Qt5Multimedia_FOUND)
list(APPEND QT_LIBRARIES qtaudio_windows strmiids winmm)
endif()
list(APPEND QT_LIBRARIES Qt5::Multimedia)
add_definitions(-DBUILD_QT_MULTIMEDIA)
list(APPEND QT_DEFINES BUILD_QT_MULTIMEDIA)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5")
endif()
@ -161,8 +162,18 @@ if(WIN32)
list(APPEND QT_LIBRARIES qwindows imm32)
endif()
endif()
if(APPLE)
set(SHADER_DIR Applications/${PROJECT_NAME}.app/Contents/Resources)
else()
set(SHADER_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME})
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${SHADER_DIR} COMPONENT ${BINARY_NAME}-qt)
if(NOT WIN32 AND NOT APPLE)
list(APPEND QT_DEFINES QT_SHADER_DIR ${SHADER_DIR}/shaders)
endif()
add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES};${FUNCTION_DEFINES}")
set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES};${FUNCTION_DEFINES};${OS_DEFINES};${QT_DEFINES}")
list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES} ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY})
@ -183,9 +194,6 @@ endif()
if(APPLE OR WIN32)
set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
endif()
if (NOT APPLE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME} COMPONENT ${BINARY_NAME}-qt)
endif()
if(APPLE)
set(DEPLOY_OPTIONS -p platforms/libqcocoa.dylib,audio/libqtaudio_coreaudio.dylib)
if(NOT CMAKE_INSTALL_NAME_TOOL EQUAL "install_name_tool")
@ -198,5 +206,4 @@ if(APPLE)
set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R ${CROSS_ROOT})
endif()
add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/deploy-mac.py ${DEPLOY_OPTIONS} ${PROJECT_NAME}.app)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${PROJECT_NAME}.app/Contents/Resources COMPONENT ${BINARY_NAME}-qt)
endif()

View File

@ -6,11 +6,11 @@
#include "ShaderSelector.h"
#include "Display.h"
#include "GBAApp.h"
#include "VFileDevice.h"
#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QFormLayout>
#include <QGridLayout>
#include <QSpinBox>
@ -53,15 +53,23 @@ void ShaderSelector::clear() {
}
void ShaderSelector::selectShader() {
QFileDialog *dialog = GBAApp::app()->getOpenFileDialog(nullptr, tr("Load shader"), tr("%1 Shader (%.shader)").arg(projectName));
dialog->setFileMode(QFileDialog::Directory);
dialog->exec();
QStringList names = dialog->selectedFiles();
#ifdef QT_SHADER_DIR
QFileDialog dialog(nullptr, tr("Load shader"), QT_SHADER_DIR, tr("%1 Shader (%.shader)").arg(projectName));
#else
QString path = QCoreApplication::applicationDirPath();
#ifdef Q_OS_MAC
path += QLatin1String("/../Resources");
#endif
path += QLatin1String("/shaders");
QFileDialog dialog(nullptr, tr("Load shader"), path, tr("%1 Shader (%.shader)").arg(projectName));
#endif
dialog.setFileMode(QFileDialog::Directory);
dialog.exec();
QStringList names = dialog.selectedFiles();
if (names.count() == 1) {
loadShader(names[0]);
refreshShaders();
}
delete dialog;
refreshShaders();
}
void ShaderSelector::loadShader(const QString& path) {