2023-03-23 21:53:43 +00:00
|
|
|
cmake_minimum_required(VERSION 3.20)
|
2024-05-10 19:37:25 +00:00
|
|
|
project(snes9x-qt VERSION 1.63)
|
2023-03-23 21:53:43 +00:00
|
|
|
|
2024-04-30 19:39:07 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2024-10-07 19:24:26 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2023-03-23 21:53:43 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_GLOBAL_AUTOGEN_TARGET ON)
|
|
|
|
|
|
|
|
set(DEFINES SNES9X_QT)
|
|
|
|
set(SNES9X_CORE_SOURCES
|
|
|
|
../fxinst.cpp
|
|
|
|
../fxemu.cpp
|
|
|
|
../fxdbg.cpp
|
|
|
|
../c4.cpp
|
|
|
|
../c4emu.cpp
|
|
|
|
../apu/apu.cpp
|
|
|
|
../apu/bapu/dsp/sdsp.cpp
|
|
|
|
../apu/bapu/smp/smp.cpp
|
|
|
|
../apu/bapu/smp/smp_state.cpp
|
|
|
|
../msu1.cpp
|
|
|
|
../msu1.h
|
|
|
|
../dsp.cpp
|
|
|
|
../dsp1.cpp
|
|
|
|
../dsp2.cpp
|
|
|
|
../dsp3.cpp
|
|
|
|
../dsp4.cpp
|
|
|
|
../spc7110.cpp
|
|
|
|
../obc1.cpp
|
|
|
|
../seta.cpp
|
|
|
|
../seta010.cpp
|
|
|
|
../seta011.cpp
|
|
|
|
../seta018.cpp
|
|
|
|
../controls.cpp
|
|
|
|
../crosshairs.cpp
|
|
|
|
../cpu.cpp
|
|
|
|
../sa1.cpp
|
|
|
|
../debug.cpp
|
|
|
|
../sdd1.cpp
|
|
|
|
../tile.cpp
|
|
|
|
../tileimpl-n1x1.cpp
|
|
|
|
../tileimpl-n2x1.cpp
|
|
|
|
../tileimpl-h2x1.cpp
|
|
|
|
../srtc.cpp
|
|
|
|
../gfx.cpp
|
|
|
|
../memmap.cpp
|
|
|
|
../clip.cpp
|
|
|
|
../ppu.cpp
|
|
|
|
../dma.cpp
|
|
|
|
../snes9x.cpp
|
|
|
|
../globals.cpp
|
|
|
|
../stream.cpp
|
|
|
|
../conffile.cpp
|
|
|
|
../bsx.cpp
|
|
|
|
../snapshot.cpp
|
|
|
|
../screenshot.cpp
|
|
|
|
../movie.cpp
|
|
|
|
../statemanager.cpp
|
|
|
|
../sha256.cpp
|
|
|
|
../bml.cpp
|
|
|
|
../cpuops.cpp
|
|
|
|
../cpuexec.cpp
|
|
|
|
../sa1cpu.cpp
|
|
|
|
../cheats.cpp
|
|
|
|
../cheats2.cpp
|
|
|
|
../sdd1emu.cpp
|
|
|
|
../netplay.cpp
|
|
|
|
../server.cpp
|
|
|
|
../loadzip.cpp
|
|
|
|
../fscompat.cpp)
|
|
|
|
add_library(snes9x-core ${SNES9X_CORE_SOURCES})
|
|
|
|
target_include_directories(snes9x-core PRIVATE ../)
|
2024-09-15 15:14:46 +00:00
|
|
|
target_compile_definitions(snes9x-core PRIVATE ${DEFINES} ZLIB HAVE_STDINT_H HAVE_LIBPNG ALLOW_CPU_OVERCLOCK)
|
2023-03-23 21:53:43 +00:00
|
|
|
|
2023-08-08 21:15:49 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
2023-11-29 00:30:45 +00:00
|
|
|
set(PREBUILT_QT "${PROJECT_SOURCE_DIR}/../external/qt6-mingw-clang-bin")
|
|
|
|
if (EXISTS ${PREBUILT_QT})
|
|
|
|
message("Using existing Qt6 build at ${PREBUILT_QT}")
|
|
|
|
set(CMAKE_PREFIX_PATH ${PREBUILT_QT})
|
|
|
|
else()
|
|
|
|
message("Getting Qt6 binaries...")
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(qt6-mingw-clang-bin
|
|
|
|
GIT_REPOSITORY https://github.com/bearoso/qt6-mingw-clang-bin.git
|
|
|
|
GIT_TAG main)
|
|
|
|
FetchContent_MakeAvailable(qt6-mingw-clang-bin)
|
|
|
|
set(CMAKE_PREFIX_PATH ${qt6-mingw-clang-bin_SOURCE_DIR})
|
|
|
|
endif()
|
2023-08-08 21:15:49 +00:00
|
|
|
endif()
|
2023-03-23 21:53:43 +00:00
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Widgets Gui)
|
2023-08-08 21:15:49 +00:00
|
|
|
list(APPEND LIBS Qt6::Widgets Qt6::Gui)
|
|
|
|
list(APPEND INCLUDES ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
|
|
|
|
|
2023-03-23 21:53:43 +00:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(ZLIB REQUIRED zlib)
|
2024-09-15 15:14:46 +00:00
|
|
|
pkg_check_modules(PNG REQUIRED libpng)
|
2024-12-13 23:14:34 +00:00
|
|
|
list(APPEND INCLUDES ${ZLIB_INCLUDE_DIRS})
|
|
|
|
list(APPEND FLAGS ${ZLIB_COMPILE_FLAGS})
|
2023-03-23 21:53:43 +00:00
|
|
|
|
2023-08-08 21:15:49 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
2024-04-22 20:29:19 +00:00
|
|
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
|
|
|
message("Clang compiler, using libc++.")
|
|
|
|
list(APPEND LIBS libc++.a)
|
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
|
|
|
message("GNU compiler, using libstdc++.")
|
|
|
|
list(APPEND LIBS libstdc++.a)
|
|
|
|
endif()
|
|
|
|
|
2024-12-13 23:14:34 +00:00
|
|
|
list(APPEND LIBS libz.a libpng.a opengl32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32 dinput8)
|
2023-08-08 21:15:49 +00:00
|
|
|
list(APPEND PLATFORM_SOURCES
|
2024-08-10 23:03:55 +00:00
|
|
|
../common/video/opengl/wgl_context.cpp
|
2023-08-08 21:15:49 +00:00
|
|
|
../external/glad/src/wgl.c
|
|
|
|
src/resources/snes9x_win32.rc)
|
|
|
|
else()
|
|
|
|
|
|
|
|
pkg_check_modules(WAYLAND REQUIRED wayland-client wayland-egl)
|
|
|
|
include(FindX11)
|
|
|
|
if(NOT X11_FOUND)
|
|
|
|
error()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND INCLUDES ${WAYLAND_INCLUDE_DIRS} ${X11_INCLUDE_DIRS})
|
2024-12-13 23:14:34 +00:00
|
|
|
list(APPEND LIBS ${WAYLAND_LIBRARIES} ${PNG_LIBRARIES} ${X11_LIBRARIES} ${ZLIB_LIBRARIES})
|
2023-08-08 21:15:49 +00:00
|
|
|
list(APPEND FLAGS ${WAYLAND_CFLAGS})
|
|
|
|
|
|
|
|
pkg_check_modules(PULSEAUDIO libpulse)
|
|
|
|
if(PULSEAUDIO_FOUND)
|
|
|
|
list(APPEND LIBS ${PULSEAUDIO_LIBRARIES})
|
|
|
|
list(APPEND INCLUDES ${PULSEAUDIO_INCLUDE_DIRS})
|
|
|
|
list(APPEND DEFINES "USE_PULSEAUDIO")
|
|
|
|
list(APPEND PLATFORM_SOURCES ../common/audio/s9x_sound_driver_pulse.cpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND PLATFORM_SOURCES
|
2024-08-10 22:00:40 +00:00
|
|
|
../common/video/opengl/glx_context.cpp
|
|
|
|
../common/video/opengl/glx_context.hpp
|
|
|
|
../common/video/opengl/wayland_egl_context.cpp
|
|
|
|
../common/video/opengl/wayland_egl_context.hpp
|
|
|
|
../common/video/wayland/wayland_surface.cpp
|
|
|
|
../common/video/wayland/wayland_surface.hpp
|
|
|
|
../common/video/wayland/fractional-scale-v1.c
|
|
|
|
../common/video/wayland/fractional-scale-v1.h
|
|
|
|
../common/video/wayland/viewporter-client-protocol.c
|
|
|
|
../common/video/wayland/viewporter-client-protocol.h
|
|
|
|
../common/video/wayland/wayland-idle-inhibit-unstable-v1.c
|
|
|
|
../common/video/wayland/wayland-idle-inhibit-unstable-v1.h
|
2023-08-08 21:15:49 +00:00
|
|
|
../external/glad/src/glx.c
|
|
|
|
../external/glad/src/egl.c)
|
2023-06-29 22:44:13 +00:00
|
|
|
endif()
|
2023-03-23 21:53:43 +00:00
|
|
|
|
2024-12-14 01:47:15 +00:00
|
|
|
find_package(SDL3 QUIET)
|
|
|
|
if (SDL3_FOUND AND (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
|
|
|
|
message("Using system SDL3.")
|
|
|
|
list(APPEND LIBS SDL3::SDL3)
|
|
|
|
list(APPEND INCLUDES ${SDL3_INCLUDE_DIRS})
|
|
|
|
else()
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
|
|
SDL3
|
|
|
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
|
|
|
GIT_TAG 313d522f39c5b6aa9fa3498d41c75c7d560250da
|
|
|
|
GIT_SHALLOW TRUE
|
|
|
|
GIT_PROGRESS TRUE
|
|
|
|
EXCLUDE_FROM_ALL
|
|
|
|
)
|
|
|
|
message(STATUS "Using SDL3 via FetchContent")
|
|
|
|
set(SDL_UNIX_CONSOLE_BUILD FORCE CACHE BOOL ON)
|
|
|
|
set(SDL_GPU CACHE BOOL OFF)
|
|
|
|
set(SDL_VIDEO CACHE BOOL OFF)
|
|
|
|
set(SDL_RENDER CACHE BOOL OFF)
|
|
|
|
set(SDL_SHARED BOOL FALSE)
|
|
|
|
set(SDL_STATIC BOOL TRUE)
|
|
|
|
FetchContent_MakeAvailable(SDL3)
|
|
|
|
list(APPEND INCLUDES ${SDL3_SOURCE_DIR}/include)
|
|
|
|
list(APPEND LIBS SDL3::SDL3-static)
|
2024-12-14 01:12:54 +00:00
|
|
|
endif()
|
2024-12-13 23:14:34 +00:00
|
|
|
|
|
|
|
list(APPEND DEFINES SDL_MAIN_HANDLED)
|
|
|
|
|
2023-11-30 22:58:25 +00:00
|
|
|
list(APPEND PLATFORM_SOURCES ../external/fmt/src/format.cc)
|
|
|
|
list(APPEND INCLUDES ../external/fmt/include)
|
|
|
|
|
2023-06-29 22:44:13 +00:00
|
|
|
list(APPEND QT_GUI_SOURCES
|
2023-03-23 21:53:43 +00:00
|
|
|
src/main.cpp
|
|
|
|
src/EmuApplication.cpp
|
|
|
|
src/EmuMainWindow.cpp
|
|
|
|
src/Snes9xController.cpp
|
|
|
|
src/EmuSettingsWindow.cpp
|
|
|
|
src/EmuConfig.cpp
|
|
|
|
src/EmuBinding.cpp
|
|
|
|
src/EmuCanvas.cpp
|
|
|
|
src/BindingPanel.cpp
|
|
|
|
src/ControllerPanel.cpp
|
|
|
|
src/DisplayPanel.cpp
|
|
|
|
src/SoundPanel.cpp
|
|
|
|
src/EmulationPanel.cpp
|
|
|
|
src/ShortcutsPanel.cpp
|
|
|
|
src/GeneralPanel.cpp
|
|
|
|
src/FoldersPanel.cpp
|
|
|
|
src/SDLInputManager.cpp
|
|
|
|
src/ShaderParametersDialog.cpp
|
2023-08-14 14:34:19 +00:00
|
|
|
src/CheatsDialog.cpp
|
2023-03-23 21:53:43 +00:00
|
|
|
src/SoftwareScalers.cpp
|
|
|
|
src/EmuCanvasQt.cpp
|
|
|
|
src/EmuCanvasOpenGL.cpp
|
|
|
|
src/EmuCanvasVulkan.cpp
|
|
|
|
../external/glad/src/gl.c
|
2024-12-13 23:14:34 +00:00
|
|
|
../common/audio/s9x_sound_driver_sdl3.cpp
|
|
|
|
../common/audio/s9x_sound_driver_sdl3.hpp
|
2023-03-23 21:53:43 +00:00
|
|
|
../common/audio/s9x_sound_driver_cubeb.cpp
|
|
|
|
../common/audio/s9x_sound_driver_cubeb.hpp
|
|
|
|
../filter/2xsai.cpp
|
|
|
|
../filter/2xsai.h
|
|
|
|
../filter/epx.cpp
|
|
|
|
../filter/epx.h
|
|
|
|
../filter/snes_ntsc_config.h
|
|
|
|
../filter/snes_ntsc.h
|
|
|
|
../filter/snes_ntsc_impl.h
|
|
|
|
../filter/snes_ntsc.c)
|
|
|
|
|
|
|
|
set(QT_UI_FILES
|
|
|
|
src/GeneralPanel.ui
|
|
|
|
src/ControllerPanel.ui
|
|
|
|
src/EmuSettingsWindow.ui
|
|
|
|
src/DisplayPanel.ui
|
|
|
|
src/SoundPanel.ui
|
|
|
|
src/EmulationPanel.ui
|
|
|
|
src/ShortcutsPanel.ui
|
|
|
|
src/FoldersPanel.ui)
|
|
|
|
|
|
|
|
set(USE_SANITIZERS CACHE BOOL OFF)
|
|
|
|
set(BUILD_TESTS CACHE BOOL OFF)
|
|
|
|
set(BUILD_TOOLS CACHE BOOL OFF)
|
2023-08-05 21:59:56 +00:00
|
|
|
set(BUNDLE_SPEEX FORCE BOOL ON)
|
2023-03-23 21:53:43 +00:00
|
|
|
add_subdirectory("../external/cubeb" "cubeb" EXCLUDE_FROM_ALL)
|
|
|
|
list(APPEND LIBS cubeb)
|
|
|
|
list(APPEND INCLUDES "../external/cubeb/include")
|
|
|
|
|
|
|
|
set(BUILD_TESTING CACHE BOOL OFF)
|
|
|
|
add_subdirectory("../external/glslang" "glslang" EXCLUDE_FROM_ALL)
|
|
|
|
list(APPEND LIBS
|
|
|
|
glslang
|
|
|
|
OGLCompiler
|
|
|
|
HLSL
|
|
|
|
OSDependent
|
|
|
|
SPIRV
|
|
|
|
glslang-default-resource-limits)
|
|
|
|
list(APPEND INCLUDES "../external/glslang")
|
|
|
|
|
|
|
|
set(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS CACHE BOOL ON)
|
|
|
|
add_subdirectory("../external/SPIRV-Cross" "SPIRV-Cross" EXCLUDE_FROM_ALL)
|
|
|
|
list(APPEND LIBS
|
|
|
|
spirv-cross-core
|
|
|
|
spirv-cross-glsl
|
|
|
|
spirv-cross-reflect
|
|
|
|
spirv-cross-cpp)
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
|
|
list(APPEND DEFINES "VK_USE_PLATFORM_WIN32_KHR")
|
|
|
|
else()
|
|
|
|
list(APPEND DEFINES
|
|
|
|
"VK_USE_PLATFORM_XLIB_KHR"
|
|
|
|
"VK_USE_PLATFORM_WAYLAND_KHR")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND DEFINES
|
|
|
|
"VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1"
|
2024-04-12 23:47:16 +00:00
|
|
|
"VULKAN_HPP_NO_NODISCARD_WARNINGS=1"
|
|
|
|
"VULKAN_HPP_NO_EXCEPTIONS=1"
|
2023-03-23 21:53:43 +00:00
|
|
|
"VMA_DYNAMIC_VULKAN_FUNCTIONS=1"
|
|
|
|
"VMA_STATIC_VULKAN_FUNCTIONS=0"
|
|
|
|
"USE_SLANG")
|
|
|
|
list(APPEND INCLUDES
|
|
|
|
../external/vulkan-headers/include
|
|
|
|
../external/VulkanMemoryAllocator-Hpp/include
|
|
|
|
../external/stb
|
|
|
|
"../external/glad/include")
|
|
|
|
list(APPEND SOURCES
|
2024-08-10 22:41:47 +00:00
|
|
|
../common/video/vulkan/slang_shader.cpp
|
|
|
|
../common/video/vulkan/slang_shader.hpp
|
|
|
|
../common/video/vulkan/slang_preset.cpp
|
|
|
|
../common/video/vulkan/slang_preset.hpp
|
|
|
|
../common/video/vulkan/vulkan_hpp_storage.cpp
|
|
|
|
../common/video/vulkan/vk_mem_alloc_implementation.cpp
|
|
|
|
../common/video/vulkan/vulkan_context.cpp
|
|
|
|
../common/video/vulkan/vulkan_context.hpp
|
2024-10-17 20:15:21 +00:00
|
|
|
../common/video/vulkan/vulkan_common.cpp
|
|
|
|
../common/video/vulkan/vulkan_common.hpp
|
2024-08-10 22:41:47 +00:00
|
|
|
../common/video/vulkan/vulkan_texture.cpp
|
|
|
|
../common/video/vulkan/vulkan_texture.hpp
|
|
|
|
../common/video/vulkan/vulkan_swapchain.cpp
|
|
|
|
../common/video/vulkan/vulkan_swapchain.hpp
|
|
|
|
../common/video/vulkan/vulkan_slang_pipeline.cpp
|
|
|
|
../common/video/vulkan/vulkan_slang_pipeline.hpp
|
|
|
|
../common/video/vulkan/vulkan_pipeline_image.cpp
|
|
|
|
../common/video/vulkan/vulkan_pipeline_image.hpp
|
|
|
|
../common/video/vulkan/vulkan_shader_chain.cpp
|
|
|
|
../common/video/vulkan/vulkan_shader_chain.hpp
|
|
|
|
../common/video/vulkan/vulkan_simple_output.hpp
|
|
|
|
../common/video/vulkan/vulkan_simple_output.cpp
|
|
|
|
../common/video/std_chrono_throttle.cpp
|
|
|
|
../common/video/std_chrono_throttle.hpp
|
|
|
|
../common/video/vulkan/slang_helpers.cpp
|
|
|
|
../common/video/vulkan/slang_helpers.hpp
|
|
|
|
../common/video/vulkan/slang_preset_ini.cpp
|
|
|
|
../common/video/vulkan/slang_preset_ini.hpp
|
2023-03-23 21:53:43 +00:00
|
|
|
../external/stb/stb_image_implementation.cpp
|
2024-08-10 22:08:57 +00:00
|
|
|
../common/video/opengl/shaders/glsl.cpp
|
|
|
|
../common/video/opengl/shaders/slang.cpp
|
|
|
|
../common/video/opengl/shaders/shader_helpers.cpp)
|
2023-03-23 21:53:43 +00:00
|
|
|
|
|
|
|
list(APPEND DEFINES "IMGUI_IMPL_VULKAN_NO_PROTOTYPES")
|
|
|
|
list(APPEND SOURCES ../external/imgui/imgui.cpp
|
|
|
|
../external/imgui/imgui_demo.cpp
|
|
|
|
../external/imgui/imgui_draw.cpp
|
|
|
|
../external/imgui/imgui_tables.cpp
|
|
|
|
../external/imgui/imgui_widgets.cpp
|
|
|
|
../external/imgui/imgui_impl_opengl3.cpp
|
|
|
|
../external/imgui/imgui_impl_vulkan.cpp
|
|
|
|
../external/imgui/snes9x_imgui.cpp)
|
|
|
|
list(APPEND INCLUDES ../external/imgui)
|
|
|
|
|
|
|
|
add_executable(snes9x-qt ${QT_GUI_SOURCES} ${SOURCES} ${PLATFORM_SOURCES} src/resources/snes9x.qrc)
|
2023-08-05 21:59:56 +00:00
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
2023-08-08 21:15:49 +00:00
|
|
|
set_target_properties(snes9x-qt PROPERTIES WIN32_EXECUTABLE True)
|
2023-08-05 21:59:56 +00:00
|
|
|
endif()
|
2024-10-07 19:24:26 +00:00
|
|
|
target_link_libraries(snes9x-qt PRIVATE snes9x-core ${LIBS})
|
2023-03-23 21:53:43 +00:00
|
|
|
target_compile_definitions(snes9x-qt PRIVATE ${DEFINES})
|
|
|
|
target_compile_options(snes9x-qt PRIVATE ${FLAGS})
|
|
|
|
target_include_directories(snes9x-qt PRIVATE "../" ${INCLUDES})
|
|
|
|
|
2024-04-30 19:39:07 +00:00
|
|
|
install(TARGETS snes9x-qt)
|
|
|
|
install(FILES ../data/cheats.bml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/snes9x)
|