Merged the SDL and Qt frontends together into a single unified executable

This commit is contained in:
OpenSauce04
2024-11-09 20:23:49 +00:00
parent f939b981a0
commit c399783266
49 changed files with 501 additions and 734 deletions

View File

@@ -0,0 +1,79 @@
add_executable(citra_meta
citra.rc
main.cpp
)
set_target_properties(citra_meta PROPERTIES OUTPUT_NAME "citra")
if (APPLE)
set(DIST_DIR "../../dist/apple")
set(APPLE_RESOURCES
"${DIST_DIR}/citra.icns"
"${DIST_DIR}/LaunchScreen.storyboard"
"${DIST_DIR}/launch_logo.png"
)
target_sources(citra_meta PRIVATE ${APPLE_RESOURCES})
# Define app bundle metadata.
include(GenerateBuildInfo)
set_target_properties(citra_meta PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${DIST_DIR}/Info.plist.in"
MACOSX_BUNDLE_BUNDLE_NAME "Citra"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.citra-emu.citra"
MACOSX_BUNDLE_BUNDLE_VERSION "${BUILD_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${BUILD_FULLNAME}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${BUILD_FULLNAME}"
MACOSX_BUNDLE_ICON_FILE "citra.icns"
RESOURCE "${APPLE_RESOURCES}"
)
if (IOS)
set_target_properties(citra_meta PROPERTIES
# Have Xcode copy and sign MoltenVK into app bundle.
XCODE_EMBED_FRAMEWORKS "${MOLTENVK_LIBRARY}"
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY YES
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks"
# Support iPhone and iPad.
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
)
endif()
endif()
target_link_libraries(citra_meta PRIVATE fmt)
if (ENABLE_SDL2_FRONTEND)
target_link_libraries(citra_meta PRIVATE citra_sdl)
endif()
if (ENABLE_QT)
target_link_libraries(citra_meta PRIVATE citra_qt)
target_link_libraries(citra_meta PRIVATE Boost::boost Qt6::Widgets)
endif()
if (ENABLE_QT AND UNIX AND NOT APPLE)
target_link_libraries(citra_meta PRIVATE Qt6::DBus gamemode)
endif()
if (ENABLE_QT AND USE_DISCORD_PRESENCE)
target_link_libraries(citra_meta PRIVATE discord-rpc)
endif()
if(WIN32)
# compile as a win32 gui application instead of a console application
if(MSVC)
set_target_properties(citra_meta PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
elseif(MINGW)
set_target_properties(citra_meta PROPERTIES LINK_FLAGS_RELEASE "-mwindows")
endif()
endif()
# Bundle in-place on MSVC so dependencies can be resolved by builds.
if (ENABLE_QT AND MSVC)
include(BundleTarget)
qt_bundle_target_in_place(citra_meta)
endif()
if(UNIX AND NOT APPLE)
install(TARGETS citra_meta RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()

19
src/citra_meta/citra.rc Normal file
View File

@@ -0,0 +1,19 @@
#include "winresrc.h"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
// QT requires that the default application icon is named IDI_ICON1
IDI_ICON1 ICON "../../dist/citra.ico"
/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//
0 RT_MANIFEST "../../dist/citra.manifest"

View File

@@ -0,0 +1,29 @@
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <string>
namespace Common {
constexpr char help_string[] =
"Usage: {} [options] <file path>\n"
"-d, --dump-video [path] Dump video recording of emulator playback to the given file path\n"
"-f, --fullscreen Start in fullscreen mode\n"
"-g, --gdbport [port] Enable gdb stub on the given port\n"
"-h, --help Display this help and exit\n"
"-i, --install [path] Install a CIA file at the given path\n"
"-p, --movie-play [path] Play a TAS movie located at the given path\n"
"-r, --movie-record [path] Record a TAS movie to the given file path\n"
"-a, --movie-record-author [author] Set the author for the recorded TAS movie (to be used "
"alongside --movie-record)\n"
"-n, --no-gui Use the lightweight SDL frontend instead of the usual Qt "
"frontend\n"
"-m, --multiplayer [nick:password@address:port] Nickname, password, address and port for "
"multiplayer\n"
"-v, --version Output version information and exit\n"
"-w, --windowed Start in windowed mode";
}

45
src/citra_meta/main.cpp Normal file
View File

@@ -0,0 +1,45 @@
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <iostream>
#ifdef ENABLE_QT
#include "citra_qt/citra_qt.h"
#endif
#ifdef ENABLE_SDL2_FRONTEND
#include "citra_sdl/citra_sdl.h"
#endif
#ifdef _WIN32
extern "C" {
// tells Nvidia drivers to use the dedicated GPU by default on laptops with switchable graphics
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
}
#endif
int main(int argc, char* argv[]) {
#if ENABLE_QT
bool no_gui = false;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--no-gui") == 0 || strcmp(argv[i], "-n") == 0) {
no_gui = true;
}
}
if (!no_gui) {
LaunchQtFrontend(argc, argv);
return 0;
}
#endif
#if ENABLE_SDL2_FRONTEND
LaunchSdlFrontend(argc, argv);
#else
std::cout << "Cannot use SDL frontend as it was excluded at compile time. Exiting."
<< std::endl;
return -1;
#endif
return 0;
}