From f375ee72a2c8c04ce7d74425026a41011aa8f697 Mon Sep 17 00:00:00 2001 From: mazes-80 Date: Mon, 3 Sep 2018 18:09:23 +0200 Subject: [PATCH] CMake: Add option to enable/disable Vulkan video backend --- CMakeLists.txt | 8 +++++++- Source/Core/Core/CMakeLists.txt | 5 ++++- Source/Core/VideoBackends/CMakeLists.txt | 4 +++- Source/Core/VideoCommon/VideoBackendBase.cpp | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2fc6e0789..fdccd03027 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ option(ENABLE_ALSA "Enables ALSA sound backend" ON) option(ENABLE_PULSEAUDIO "Enables PulseAudio sound backend" ON) option(ENABLE_LLVM "Enables LLVM support, for disassembly" ON) option(ENABLE_TESTS "Enables building the unit tests" ON) +option(ENABLE_VULKAN "Enables vulkan video backend" ON) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence, show the current game on Discord" ON) # Maintainers: if you consider blanket disabling this for your users, please @@ -543,6 +544,7 @@ if (_M_X86) add_subdirectory(Externals/Bochs_disasm) endif() add_subdirectory(Externals/cpp-optparse) + find_package(fmt 6.0) if(fmt_FOUND) message(STATUS "Using shared fmt ${fmt_VERSION}") @@ -551,8 +553,12 @@ else() message(STATUS "Using static fmt from Externals") add_subdirectory(Externals/fmt EXCLUDE_FROM_ALL) endif() -add_subdirectory(Externals/glslang) add_subdirectory(Externals/imgui) +add_subdirectory(Externals/glslang) + +if(ENABLE_VULKAN) + add_definitions(-DUSE_VULKAN) +endif() find_package(pugixml) if(NOT pugixml_FOUND) diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index d1fa581955..db3f2584a7 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -563,7 +563,6 @@ PUBLIC videonull videoogl videosoftware - videovulkan PRIVATE fmt::fmt @@ -601,6 +600,10 @@ if(LIBUSB_FOUND) ) endif() +if(ENABLE_VULKAN) + target_link_libraries(core PUBLIC videovulkan) +endif() + if(WIN32) target_sources(core PRIVATE HW/EXI/BBA/TAP_Win32.cpp diff --git a/Source/Core/VideoBackends/CMakeLists.txt b/Source/Core/VideoBackends/CMakeLists.txt index 51ea342826..3ab2d4c4e4 100644 --- a/Source/Core/VideoBackends/CMakeLists.txt +++ b/Source/Core/VideoBackends/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(OGL) add_subdirectory(Null) add_subdirectory(Software) -add_subdirectory(Vulkan) if(CMAKE_SYSTEM_NAME STREQUAL "Windows") add_subdirectory(D3DCommon) @@ -9,3 +8,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") add_subdirectory(D3D12) endif() +if(ENABLE_VULKAN) + add_subdirectory(Vulkan) +endif() diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index ef490c60c8..690745f9c8 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -225,7 +225,9 @@ const std::vector>& VideoBackendBase::GetAvail backends.push_back(std::make_unique()); backends.push_back(std::make_unique()); #endif +#ifdef USE_VULKAN backends.push_back(std::make_unique()); +#endif #ifdef HAS_OPENGL backends.push_back(std::make_unique()); #endif