CMake: Remove unsupported options

This commit is contained in:
Stenzek 2023-09-16 14:39:13 +10:00
parent c773c763ef
commit a37e89b52f
18 changed files with 173 additions and 318 deletions

View file

@ -15,55 +15,32 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules/")
# Platform detection.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX TRUE)
set(SUPPORTS_X11 TRUE)
set(SUPPORTS_WAYLAND TRUE)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(FREEBSD TRUE)
set(SUPPORTS_X11 TRUE)
endif()
# Global options.
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF)
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
option(BUILD_REGTEST "Build regression test runner" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
option(ENABLE_CUBEB "Build with Cubeb audio output" ON)
# Renderer options.
option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
option(ENABLE_DISCORD_PRESENCE "Build with Discord Rich Presence support" ON)
#option(USE_SDL2 "Link with SDL2 for controller support" ON)
set(USE_SDL2 ON)
# Global options.
if(NOT ANDROID)
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF)
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
option(BUILD_REGTEST "Build regression test runner" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
# OpenGL context creation methods.
if(SUPPORTS_X11)
set(ENABLE_CUBEB ON)
set(ENABLE_DISCORD_PRESENCE ON)
set(USE_SDL2 ON)
if(LINUX OR FREEBSD)
option(USE_X11 "Support X11 window system" ON)
endif()
if(SUPPORTS_WAYLAND)
option(USE_WAYLAND "Support Wayland window system" ON)
endif()
if((LINUX OR FREEBSD) AND NOT ANDROID)
option(USE_DBUS "Enable DBus support for screensaver inhibiting" ON)
endif()
if(APPLE)
option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF)
endif()
if(ANDROID)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
set(BUILD_NOGUI_FRONTEND OFF CACHE BOOL "")
set(BUILD_QT_FRONTEND OFF CACHE BOOL "")
set(BUILD_REGTEST OFF CACHE BOOL "")
set(ENABLE_CUBEB OFF CACHE BOOL "")
set(ENABLE_OPENGL ON CACHE BOOL "")
set(ENABLE_VULKAN ON CACHE BOOL "")
set(ENABLE_DISCORD_PRESENCE OFF CACHE BOOL "")
set(ENABLE_CHEEVOS ON CACHE BOOL "")
set(USE_SDL2 OFF CACHE BOOL "")
set(USE_X11 OFF CACHE BOOL "")
set(USE_WAYLAND OFF CACHE BOOL "")
if(APPLE)
option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF)
endif()
endif()
@ -73,10 +50,12 @@ if(USE_SDL2)
endif()
if(NOT WIN32 AND NOT ANDROID)
find_package(CURL REQUIRED)
if(NOT APPLE)
find_package(Libbacktrace)
if(NOT LIBBACKTRACE_FOUND)
message(WARNING "libbacktrace not found, crashes will not produce backtraces.")
endif()
endif()
endif()
if(BUILD_QT_FRONTEND)
find_package(Qt6 6.5.1 COMPONENTS Core Gui Widgets Network LinguistTools REQUIRED)
@ -99,9 +78,6 @@ endif()
if(USE_WAYLAND)
message(STATUS "Wayland support enabled")
endif()
if(ENABLE_CHEEVOS)
message(STATUS "RetroAchievements support enabled")
endif()
# Set _DEBUG macro for Debug builds.

View file

@ -1,46 +0,0 @@
# This module can be used in two different ways.
#
# When invoked as `cmake -P DolphinPostprocessBundle.cmake`, it fixes up an
# application folder to be standalone. It bundles all required libraries from
# the system and fixes up library IDs. Any additional shared libraries, like
# plugins, that are found under Contents/MacOS/ will be made standalone as well.
#
# When called with `include(DolphinPostprocessBundle)`, it defines a helper
# function `dolphin_postprocess_bundle` that sets up the command form of the
# module as a post-build step.
if(CMAKE_GENERATOR)
# Being called as include(DolphinPostprocessBundle), so define a helper function.
set(_DOLPHIN_POSTPROCESS_BUNDLE_MODULE_LOCATION "${CMAKE_CURRENT_LIST_FILE}")
function(dolphin_postprocess_bundle target)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -DDOLPHIN_BUNDLE_PATH="$<TARGET_FILE_DIR:${target}>/../.."
-P "${_DOLPHIN_POSTPROCESS_BUNDLE_MODULE_LOCATION}"
)
endfunction()
return()
endif()
get_filename_component(DOLPHIN_BUNDLE_PATH "${DOLPHIN_BUNDLE_PATH}" ABSOLUTE)
message(STATUS "Fixing up application bundle: ${DOLPHIN_BUNDLE_PATH}")
# Make sure to fix up any additional shared libraries (like plugins) that are
# needed.
file(GLOB_RECURSE extra_libs "${DOLPHIN_BUNDLE_PATH}/Contents/MacOS/*.dylib")
# BundleUtilities doesn't support DYLD_FALLBACK_LIBRARY_PATH behavior, which
# makes it sometimes break on libraries that do weird things with @rpath. Specify
# equivalent search directories until https://gitlab.kitware.com/cmake/cmake/issues/16625
# is fixed and in our minimum CMake version.
set(extra_dirs "/usr/local/lib" "/lib" "/usr/lib")
# BundleUtilities is overly verbose, so disable most of its messages
function(message)
if(NOT ARGV MATCHES "^STATUS;")
_message(${ARGV})
endif()
endfunction()
include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS ON)
fixup_bundle("${DOLPHIN_BUNDLE_PATH}" "${extra_libs}" "${extra_dirs}")

View file

@ -3219,7 +3219,7 @@ void FullscreenUI::DrawControllerSettingsPage()
MenuHeading("Input Sources");
#ifdef WITH_SDL2
#ifdef USE_SDL2
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_COG, "Enable SDL Input Source"),
FSUI_CSTR("The SDL input source supports most controllers."), "InputSources", "SDL", true, true,
false);

View file

@ -319,7 +319,7 @@ std::unique_ptr<AudioStream> Host::CreateAudioStream(AudioBackend backend, u32 s
{
switch (backend)
{
#ifdef WITH_CUBEB
#ifdef USE_CUBEB
case AudioBackend::Cubeb:
return AudioStream::CreateCubebAudioStream(sample_rate, channels, buffer_ms, latency_ms, stretch);
#endif

View file

@ -1247,7 +1247,7 @@ const char* Settings::GetDisplayScalingDisplayName(DisplayScalingMode mode)
static constexpr const char* s_audio_backend_names[] = {
"Null",
#ifdef WITH_CUBEB
#ifdef USE_CUBEB
"Cubeb",
#endif
#ifdef _WIN32
@ -1259,7 +1259,7 @@ static constexpr const char* s_audio_backend_names[] = {
};
static constexpr const char* s_audio_backend_display_names[] = {
TRANSLATE_NOOP("AudioBackend", "Null (No Output)"),
#ifdef WITH_CUBEB
#ifdef USE_CUBEB
TRANSLATE_NOOP("AudioBackend", "Cubeb"),
#endif
#ifdef _WIN32

View file

@ -446,7 +446,7 @@ struct Settings
static constexpr CPUFastmemMode DEFAULT_CPU_FASTMEM_MODE = CPUFastmemMode::Disabled;
#endif
#if defined(WITH_CUBEB)
#if defined(USE_CUBEB)
static constexpr AudioBackend DEFAULT_AUDIO_BACKEND = AudioBackend::Cubeb;
#elif defined(_WIN32)
static constexpr AudioBackend DEFAULT_AUDIO_BACKEND = AudioBackend::XAudio2;

View file

@ -144,7 +144,7 @@ enum class DisplayScalingMode : u8
enum class AudioBackend : u8
{
Null,
#ifdef WITH_CUBEB
#ifdef USE_CUBEB
Cubeb,
#endif
#ifdef _WIN32

View file

@ -9,6 +9,12 @@ set(SRCS
aboutdialog.cpp
aboutdialog.h
aboutdialog.ui
achievementlogindialog.cpp
achievementlogindialog.h
achievementlogindialog.ui
achievementsettingswidget.cpp
achievementsettingswidget.h
achievementsettingswidget.ui
advancedsettingswidget.cpp
advancedsettingswidget.h
advancedsettingswidget.ui
@ -136,17 +142,6 @@ set(SRCS
setupwizarddialog.ui
)
if(ENABLE_CHEEVOS)
set(SRCS ${SRCS}
achievementlogindialog.cpp
achievementlogindialog.h
achievementlogindialog.ui
achievementsettingswidget.cpp
achievementsettingswidget.h
achievementsettingswidget.ui
)
endif()
set(TS_FILES
translations/duckstation-qt_de.ts
translations/duckstation-qt_en.ts

View file

@ -103,7 +103,7 @@ void AudioSettingsWidget::updateDriverNames()
std::vector<std::string> names;
std::vector<std::pair<std::string, std::string>> devices;
#ifdef WITH_CUBEB
#ifdef USE_CUBEB
if (backend == AudioBackend::Cubeb)
{
names = AudioStream::GetCubebDriverNames();

View file

@ -16,17 +16,12 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
SettingsInterface* sif = dialog->getProfileSettingsInterface();
#ifdef WITH_SDL2
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources",
"SDLControllerEnhancedMode", false);
connect(m_ui.enableSDLSource, &QCheckBox::stateChanged, this,
&ControllerGlobalSettingsWidget::updateSDLOptionsEnabled);
connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked);
#else
m_ui.enableSDLSource->setEnabled(false);
m_ui.ledSettings->setEnabled(false);
#endif
#ifdef _WIN32
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableDInputSource, "InputSources", "DInput", false);
@ -129,7 +124,6 @@ ControllerLEDSettingsDialog::~ControllerLEDSettingsDialog() = default;
void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 player_id)
{
#ifdef WITH_SDL2
std::string key(fmt::format("Player{}LED", player_id));
const u32 current_value =
SDLInputSource::ParseRGBForPlayerId(m_dialog->getStringValue("SDLExtra", key.c_str(), ""), player_id);
@ -138,5 +132,4 @@ void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 play
connect(button, &ColorPickerButton::colorChanged, this, [this, key = std::move(key)](u32 new_rgb) {
m_dialog->setStringValue("SDLExtra", key.c_str(), fmt::format("{:06X}", new_rgb).c_str());
});
#endif
}

View file

@ -74,25 +74,22 @@ target_include_directories(util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(util PUBLIC common simpleini imgui)
target_link_libraries(util PRIVATE stb libchdr zlib soundtouch Zstd::Zstd reshadefx)
if(ENABLE_CUBEB)
if(USE_CUBEB)
target_sources(util PRIVATE
cubeb_audio_stream.cpp
cubeb_audio_stream.h
)
target_compile_definitions(util PUBLIC "WITH_CUBEB=1")
target_compile_definitions(util PUBLIC "USE_CUBEB=1")
target_link_libraries(util PRIVATE cubeb)
endif()
if(USE_X11)
target_compile_definitions(util PRIVATE "-DUSE_X11=1")
target_include_directories(util PRIVATE "${X11_INCLUDE_DIR}" "${X11_Xrandr_INCLUDE_PATH}")
target_link_libraries(util PRIVATE "${X11_LIBRARIES}" "${X11_Xrandr_LIB}")
target_link_libraries(util PRIVATE X11::X11 X11::Xrandr)
endif()
if(USE_WAYLAND)
target_compile_definitions(util PRIVATE "-DUSE_WAYLAND=1")
elseif(SUPPORTS_WAYLAND)
message(WARNING "Wayland support for renderers is disabled.\nDuckStation will FAIL to start on Wayland.")
endif()
if(ENABLE_OPENGL)
@ -199,7 +196,7 @@ if(USE_SDL2)
sdl_input_source.cpp
sdl_input_source.h
)
target_compile_definitions(util PUBLIC "WITH_SDL2=1")
target_compile_definitions(util PUBLIC "USE_SDL2=1")
target_link_libraries(util PUBLIC SDL2::SDL2)
# Copy bundled SDL2 to output on Windows.
@ -215,14 +212,6 @@ if(USE_SDL2)
endif()
endif()
if(USE_DBUS)
target_compile_definitions(util PRIVATE USE_DBUS)
find_package(PkgConfig REQUIRED)
pkg_check_modules(DBUS REQUIRED dbus-1)
target_include_directories(util PRIVATE ${DBUS_INCLUDE_DIRS})
target_link_libraries(util PRIVATE ${DBUS_LINK_LIBRARIES})
endif()
if(WIN32)
target_sources(util PRIVATE
d3d_common.cpp
@ -288,6 +277,10 @@ elseif(NOT ANDROID)
target_sources(util PRIVATE
platform_misc_unix.cpp
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(DBUS REQUIRED dbus-1)
target_include_directories(util PRIVATE ${DBUS_INCLUDE_DIRS})
target_link_libraries(util PRIVATE ${DBUS_LINK_LIBRARIES})
endif()
function(add_util_resources target)

View file

@ -79,7 +79,7 @@ public:
static std::unique_ptr<AudioStream> CreateNullStream(u32 sample_rate, u32 channels, u32 buffer_ms);
#ifdef WITH_CUBEB
#ifdef USE_CUBEB
static std::unique_ptr<AudioStream> CreateCubebAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms,
u32 latency_ms, AudioStretchMode stretch);
static std::vector<std::string> GetCubebDriverNames();

View file

@ -481,7 +481,7 @@ static std::array<const char*, static_cast<u32>(InputSourceType::Count)> s_input
"XInput",
"RawInput",
#endif
#ifdef WITH_SDL2
#ifdef USE_SDL2
"SDL",
#endif
#ifdef __ANDROID__
@ -512,17 +512,12 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type)
return false;
case InputSourceType::XInput:
// Disable xinput by default if we have SDL.
#ifdef WITH_SDL2
return false;
#else
return true;
#endif
case InputSourceType::RawInput:
return false;
#endif
#ifdef WITH_SDL2
#ifdef USE_SDL2
case InputSourceType::SDL:
return true;
#endif
@ -1931,7 +1926,7 @@ void InputManager::ReloadSources(SettingsInterface& si, std::unique_lock<std::mu
UpdateInputSourceState(si, settings_lock, InputSourceType::XInput, &InputSource::CreateXInputSource);
UpdateInputSourceState(si, settings_lock, InputSourceType::RawInput, &InputSource::CreateWin32RawInputSource);
#endif
#ifdef WITH_SDL2
#ifdef USE_SDL2
UpdateInputSourceState(si, settings_lock, InputSourceType::SDL, &InputSource::CreateSDLSource);
#endif
#ifdef __ANDROID__

View file

@ -27,7 +27,7 @@ enum class InputSourceType : u32
XInput,
RawInput,
#endif
#ifdef WITH_SDL2
#ifdef USE_SDL2
SDL,
#endif
#ifdef __ANDROID__

View file

@ -74,7 +74,7 @@ public:
static std::unique_ptr<InputSource> CreateXInputSource();
static std::unique_ptr<InputSource> CreateWin32RawInputSource();
#endif
#ifdef WITH_SDL2
#ifdef USE_SDL2
static std::unique_ptr<InputSource> CreateSDLSource();
#endif
#ifdef __ANDROID__

View file

@ -1,47 +1,20 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> and contributors.
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "input_manager.h"
#include "platform_misc.h"
#include "common/log.h"
#include "common/scoped_guard.h"
#include "common/string.h"
#include "input_manager.h"
#include "platform_misc.h"
#include <cinttypes>
Log_SetChannel(PlatformMisc);
#include <cinttypes>
#include <spawn.h>
#include <unistd.h>
#if !defined(USE_DBUS) && defined(USE_X11)
#include <cstdio>
#include <sys/wait.h>
static bool SetScreensaverInhibitX11(bool inhibit, const WindowInfo& wi)
{
TinyString command;
command.AppendString("xdg-screensaver");
TinyString operation;
operation.AppendString(inhibit ? "suspend" : "resume");
TinyString id;
id.Format("0x%" PRIx64, static_cast<u64>(reinterpret_cast<uintptr_t>(wi.window_handle)));
char* argv[4] = {command.GetWriteableCharArray(), operation.GetWriteableCharArray(), id.GetWriteableCharArray(),
nullptr};
pid_t pid;
int res = posix_spawnp(&pid, "xdg-screensaver", nullptr, nullptr, argv, environ);
if (res != 0)
{
Log_ErrorPrintf("posix_spawnp() failed: %d", res);
return false;
}
return true;
}
#elif defined(USE_DBUS)
#include <dbus/dbus.h>
Log_SetChannel(PlatformMisc);
static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char* program_name, const char* reason)
{
static dbus_uint32_t s_cookie;
@ -115,33 +88,9 @@ static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char*
return true;
}
#endif
static bool SetScreensaverInhibit(bool inhibit)
{
#ifdef USE_DBUS
return SetScreensaverInhibitDBus(inhibit, "DuckStation", "DuckStation VM is running.");
#else
std::optional<WindowInfo> wi(Host::GetTopLevelWindowInfo());
if (!wi.has_value())
{
Log_ErrorPrintf("No top-level window.");
return false;
}
switch (wi->type)
{
#ifdef USE_X11
case WindowInfo::Type::X11:
return SetScreensaverInhibitX11(inhibit, wi.value());
#endif
default:
Log_ErrorPrintf("Unknown type: %u", static_cast<unsigned>(wi->type));
return false;
}
#endif
}
static bool s_screensaver_suspended;

View file

@ -5,7 +5,7 @@
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions);SOUNDTOUCH_FLOAT_SAMPLES;SOUNDTOUCH_ALLOW_SSE;ST_NO_EXCEPTION_HANDLING=1</PreprocessorDefinitions>
<PreprocessorDefinitions>WITH_CUBEB=1;WITH_SDL2=1;WITH_DINPUT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>USE_CUBEB=1;USE_SDL2=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'!='ARM64'">%(PreprocessorDefinitions);WITH_OPENGL=1;WITH_VULKAN=1</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM64'">%(PreprocessorDefinitions);SOUNDTOUCH_USE_NEON</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)dep\soundtouch\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\libchdr\include;$(SolutionDir)dep\cubeb\include;$(SolutionDir)dep\d3d12ma\include;$(SolutionDir)dep\zstd\lib</AdditionalIncludeDirectories>