From 9a6cbc98c368287144f2501bd2c6429a3488570a Mon Sep 17 00:00:00 2001 From: RSDuck Date: Wed, 12 Oct 2022 23:48:05 +0200 Subject: [PATCH] reorganise and cleanup build system it's still not good, but better than before --- CMakeLists.txt | 7 ---- src/CMakeLists.txt | 37 ++----------------- src/GPU_OpenGL.cpp | 1 + src/OpenGLSupport.h | 3 +- src/PlatformOGL.h | 9 +++++ .../duckstation/duckstation_compat.h | 0 src/{ => frontend}/duckstation/gl/context.cpp | 0 src/{ => frontend}/duckstation/gl/context.h | 0 .../duckstation/gl/context_egl.cpp | 0 .../duckstation/gl/context_egl.h | 0 .../duckstation/gl/context_egl_wayland.cpp | 0 .../duckstation/gl/context_egl_wayland.h | 0 .../duckstation/gl/context_egl_x11.cpp | 0 .../duckstation/gl/context_egl_x11.h | 0 .../duckstation/gl/context_glx.cpp | 0 .../duckstation/gl/context_glx.h | 0 .../duckstation/gl/context_wgl.cpp | 0 .../duckstation/gl/context_wgl.h | 0 src/{ => frontend}/duckstation/gl/loader.h | 0 .../duckstation/gl/x11_window.cpp | 0 .../duckstation/gl/x11_window.h | 0 src/{ => frontend}/duckstation/log.h | 0 src/{ => frontend}/duckstation/scoped_guard.h | 0 .../duckstation/window_info.cpp | 0 src/{ => frontend}/duckstation/window_info.h | 0 .../duckstation/windows_headers.h | 0 src/{ => frontend}/glad/eglplatform.h | 0 src/{ => frontend}/glad/glad.c | 0 src/{ => frontend}/glad/glad.h | 0 src/{ => frontend}/glad/glad_egl.c | 0 src/{ => frontend}/glad/glad_egl.h | 0 src/{ => frontend}/glad/glad_glx.c | 0 src/{ => frontend}/glad/glad_glx.h | 0 src/{ => frontend}/glad/glad_wgl.c | 0 src/{ => frontend}/glad/glad_wgl.h | 0 src/{ => frontend}/glad/khrplatform.h | 0 src/frontend/qt_sdl/CMakeLists.txt | 37 ++++++++++++++++++- 37 files changed, 51 insertions(+), 43 deletions(-) create mode 100644 src/PlatformOGL.h rename src/{ => frontend}/duckstation/duckstation_compat.h (100%) rename src/{ => frontend}/duckstation/gl/context.cpp (100%) rename src/{ => frontend}/duckstation/gl/context.h (100%) rename src/{ => frontend}/duckstation/gl/context_egl.cpp (100%) rename src/{ => frontend}/duckstation/gl/context_egl.h (100%) rename src/{ => frontend}/duckstation/gl/context_egl_wayland.cpp (100%) rename src/{ => frontend}/duckstation/gl/context_egl_wayland.h (100%) rename src/{ => frontend}/duckstation/gl/context_egl_x11.cpp (100%) rename src/{ => frontend}/duckstation/gl/context_egl_x11.h (100%) rename src/{ => frontend}/duckstation/gl/context_glx.cpp (100%) rename src/{ => frontend}/duckstation/gl/context_glx.h (100%) rename src/{ => frontend}/duckstation/gl/context_wgl.cpp (100%) rename src/{ => frontend}/duckstation/gl/context_wgl.h (100%) rename src/{ => frontend}/duckstation/gl/loader.h (100%) rename src/{ => frontend}/duckstation/gl/x11_window.cpp (100%) rename src/{ => frontend}/duckstation/gl/x11_window.h (100%) rename src/{ => frontend}/duckstation/log.h (100%) rename src/{ => frontend}/duckstation/scoped_guard.h (100%) rename src/{ => frontend}/duckstation/window_info.cpp (100%) rename src/{ => frontend}/duckstation/window_info.h (100%) rename src/{ => frontend}/duckstation/windows_headers.h (100%) rename src/{ => frontend}/glad/eglplatform.h (100%) rename src/{ => frontend}/glad/glad.c (100%) rename src/{ => frontend}/glad/glad.h (100%) rename src/{ => frontend}/glad/glad_egl.c (100%) rename src/{ => frontend}/glad/glad_egl.h (100%) rename src/{ => frontend}/glad/glad_glx.c (100%) rename src/{ => frontend}/glad/glad_glx.h (100%) rename src/{ => frontend}/glad/glad_wgl.c (100%) rename src/{ => frontend}/glad/glad_wgl.h (100%) rename src/{ => frontend}/glad/khrplatform.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ca70ece..297f71d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,13 +101,6 @@ endif() option(BUILD_QT_SDL "Build Qt/SDL frontend" ON) -find_package(ECM REQUIRED NO_MODULE) -list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}") - -find_package(X11 REQUIRED) -find_package(EGL REQUIRED) -find_package(Wayland REQUIRED Client) - add_subdirectory(src) if (BUILD_QT_SDL) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 267a8e94..797f04ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,39 +114,6 @@ if (MATH_LIBRARY) target_link_libraries(core PRIVATE ${MATH_LIBRARY}) endif() -if (ENABLE_OGLRENDERER) - target_sources(core PRIVATE - glad/glad.c - - duckstation/gl/context.cpp) - - if (WIN32) - target_link_libraries(core PUBLIC opengl32) - - target_sources(core PRIVATE - # the context stuff would probably be better in the frontend? - duckstation/gl/context_wgl.cpp - - glad/glad_wgl.c) - else() - target_sources(core PRIVATE - duckstation/gl/context_egl.cpp - duckstation/gl/context_egl_x11.cpp - duckstation/gl/context_glx.cpp - duckstation/gl/context_egl_wayland.cpp - duckstation/gl/x11_window.cpp - - glad/glad_egl.c - glad/glad_glx.c) - message("${X11_FOUND}") - message("${X11_LIBRARIES}") - target_link_libraries(core PRIVATE "${X11_LIBRARIES}" "${EGL_LIBRARIES}") - target_include_directories(core PRIVATE "${X11_INCLUDE_DIR}") - endif() - - target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED) -endif() - if (ENABLE_JIT) target_compile_definitions(core PUBLIC JIT_ENABLED) @@ -156,6 +123,10 @@ if (ENABLE_JIT) endif() endif() +if (ENABLE_OPENGLRENDERER) + target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED) +endif() + if (WIN32) target_link_libraries(core PRIVATE ole32 comctl32 ws2_32) elseif(NOT APPLE) diff --git a/src/GPU_OpenGL.cpp b/src/GPU_OpenGL.cpp index 79adf7a2..837d2240 100644 --- a/src/GPU_OpenGL.cpp +++ b/src/GPU_OpenGL.cpp @@ -23,6 +23,7 @@ #include "NDS.h" #include "GPU.h" +#include "GPU3D_OpenGL.h" #include "OpenGLSupport.h" #include "GPU_OpenGL_shaders.h" diff --git a/src/OpenGLSupport.h b/src/OpenGLSupport.h index 948949e6..14be01a6 100644 --- a/src/OpenGLSupport.h +++ b/src/OpenGLSupport.h @@ -22,9 +22,8 @@ #include #include -#include "glad/glad.h" - #include "Platform.h" +#include "PlatformOGL.h" namespace OpenGL diff --git a/src/PlatformOGL.h b/src/PlatformOGL.h new file mode 100644 index 00000000..bc047807 --- /dev/null +++ b/src/PlatformOGL.h @@ -0,0 +1,9 @@ +#ifndef PLATFORMOGL_H +#define PLATFORMOGL_H + +// if you don't wanna use glad for your platform +// add your header here! + +#include "frontend/glad/glad.h" + +#endif diff --git a/src/duckstation/duckstation_compat.h b/src/frontend/duckstation/duckstation_compat.h similarity index 100% rename from src/duckstation/duckstation_compat.h rename to src/frontend/duckstation/duckstation_compat.h diff --git a/src/duckstation/gl/context.cpp b/src/frontend/duckstation/gl/context.cpp similarity index 100% rename from src/duckstation/gl/context.cpp rename to src/frontend/duckstation/gl/context.cpp diff --git a/src/duckstation/gl/context.h b/src/frontend/duckstation/gl/context.h similarity index 100% rename from src/duckstation/gl/context.h rename to src/frontend/duckstation/gl/context.h diff --git a/src/duckstation/gl/context_egl.cpp b/src/frontend/duckstation/gl/context_egl.cpp similarity index 100% rename from src/duckstation/gl/context_egl.cpp rename to src/frontend/duckstation/gl/context_egl.cpp diff --git a/src/duckstation/gl/context_egl.h b/src/frontend/duckstation/gl/context_egl.h similarity index 100% rename from src/duckstation/gl/context_egl.h rename to src/frontend/duckstation/gl/context_egl.h diff --git a/src/duckstation/gl/context_egl_wayland.cpp b/src/frontend/duckstation/gl/context_egl_wayland.cpp similarity index 100% rename from src/duckstation/gl/context_egl_wayland.cpp rename to src/frontend/duckstation/gl/context_egl_wayland.cpp diff --git a/src/duckstation/gl/context_egl_wayland.h b/src/frontend/duckstation/gl/context_egl_wayland.h similarity index 100% rename from src/duckstation/gl/context_egl_wayland.h rename to src/frontend/duckstation/gl/context_egl_wayland.h diff --git a/src/duckstation/gl/context_egl_x11.cpp b/src/frontend/duckstation/gl/context_egl_x11.cpp similarity index 100% rename from src/duckstation/gl/context_egl_x11.cpp rename to src/frontend/duckstation/gl/context_egl_x11.cpp diff --git a/src/duckstation/gl/context_egl_x11.h b/src/frontend/duckstation/gl/context_egl_x11.h similarity index 100% rename from src/duckstation/gl/context_egl_x11.h rename to src/frontend/duckstation/gl/context_egl_x11.h diff --git a/src/duckstation/gl/context_glx.cpp b/src/frontend/duckstation/gl/context_glx.cpp similarity index 100% rename from src/duckstation/gl/context_glx.cpp rename to src/frontend/duckstation/gl/context_glx.cpp diff --git a/src/duckstation/gl/context_glx.h b/src/frontend/duckstation/gl/context_glx.h similarity index 100% rename from src/duckstation/gl/context_glx.h rename to src/frontend/duckstation/gl/context_glx.h diff --git a/src/duckstation/gl/context_wgl.cpp b/src/frontend/duckstation/gl/context_wgl.cpp similarity index 100% rename from src/duckstation/gl/context_wgl.cpp rename to src/frontend/duckstation/gl/context_wgl.cpp diff --git a/src/duckstation/gl/context_wgl.h b/src/frontend/duckstation/gl/context_wgl.h similarity index 100% rename from src/duckstation/gl/context_wgl.h rename to src/frontend/duckstation/gl/context_wgl.h diff --git a/src/duckstation/gl/loader.h b/src/frontend/duckstation/gl/loader.h similarity index 100% rename from src/duckstation/gl/loader.h rename to src/frontend/duckstation/gl/loader.h diff --git a/src/duckstation/gl/x11_window.cpp b/src/frontend/duckstation/gl/x11_window.cpp similarity index 100% rename from src/duckstation/gl/x11_window.cpp rename to src/frontend/duckstation/gl/x11_window.cpp diff --git a/src/duckstation/gl/x11_window.h b/src/frontend/duckstation/gl/x11_window.h similarity index 100% rename from src/duckstation/gl/x11_window.h rename to src/frontend/duckstation/gl/x11_window.h diff --git a/src/duckstation/log.h b/src/frontend/duckstation/log.h similarity index 100% rename from src/duckstation/log.h rename to src/frontend/duckstation/log.h diff --git a/src/duckstation/scoped_guard.h b/src/frontend/duckstation/scoped_guard.h similarity index 100% rename from src/duckstation/scoped_guard.h rename to src/frontend/duckstation/scoped_guard.h diff --git a/src/duckstation/window_info.cpp b/src/frontend/duckstation/window_info.cpp similarity index 100% rename from src/duckstation/window_info.cpp rename to src/frontend/duckstation/window_info.cpp diff --git a/src/duckstation/window_info.h b/src/frontend/duckstation/window_info.h similarity index 100% rename from src/duckstation/window_info.h rename to src/frontend/duckstation/window_info.h diff --git a/src/duckstation/windows_headers.h b/src/frontend/duckstation/windows_headers.h similarity index 100% rename from src/duckstation/windows_headers.h rename to src/frontend/duckstation/windows_headers.h diff --git a/src/glad/eglplatform.h b/src/frontend/glad/eglplatform.h similarity index 100% rename from src/glad/eglplatform.h rename to src/frontend/glad/eglplatform.h diff --git a/src/glad/glad.c b/src/frontend/glad/glad.c similarity index 100% rename from src/glad/glad.c rename to src/frontend/glad/glad.c diff --git a/src/glad/glad.h b/src/frontend/glad/glad.h similarity index 100% rename from src/glad/glad.h rename to src/frontend/glad/glad.h diff --git a/src/glad/glad_egl.c b/src/frontend/glad/glad_egl.c similarity index 100% rename from src/glad/glad_egl.c rename to src/frontend/glad/glad_egl.c diff --git a/src/glad/glad_egl.h b/src/frontend/glad/glad_egl.h similarity index 100% rename from src/glad/glad_egl.h rename to src/frontend/glad/glad_egl.h diff --git a/src/glad/glad_glx.c b/src/frontend/glad/glad_glx.c similarity index 100% rename from src/glad/glad_glx.c rename to src/frontend/glad/glad_glx.c diff --git a/src/glad/glad_glx.h b/src/frontend/glad/glad_glx.h similarity index 100% rename from src/glad/glad_glx.h rename to src/frontend/glad/glad_glx.h diff --git a/src/glad/glad_wgl.c b/src/frontend/glad/glad_wgl.c similarity index 100% rename from src/glad/glad_wgl.c rename to src/frontend/glad/glad_wgl.c diff --git a/src/glad/glad_wgl.h b/src/frontend/glad/glad_wgl.h similarity index 100% rename from src/glad/glad_wgl.h rename to src/frontend/glad/glad_wgl.h diff --git a/src/glad/khrplatform.h b/src/frontend/glad/khrplatform.h similarity index 100% rename from src/glad/khrplatform.h rename to src/frontend/glad/khrplatform.h diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index 3342aae2..244c5a74 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -41,8 +41,11 @@ set(SOURCES_QT_SDL ../FrontendUtil.h ../mic_blow.h + ../glad/glad.c + ../duckstation/gl/context.cpp + ${CMAKE_SOURCE_DIR}/res/melon.qrc - ) +) if (APPLE) option(USE_QT6 "Build using Qt 6 instead of 5" ON) @@ -83,6 +86,38 @@ add_compile_definitions(ARCHIVE_SUPPORT_ENABLED) add_executable(melonDS ${SOURCES_QT_SDL}) +if (WIN32) + target_link_libraries(melonDS PUBLIC opengl32) + + target_sources(melonDS PRIVATE + # the context stuff would probably be better in the frontend? + ../duckstation/gl/context_wgl.cpp + + ../glad/glad_wgl.c) +else() + # we only need ECM for Wayland + # so we only require it from here + find_package(ECM REQUIRED NO_MODULE) + list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}") + + find_package(X11 REQUIRED) + find_package(EGL REQUIRED) + find_package(Wayland REQUIRED Client) + + target_sources(melonDS PRIVATE + ../duckstation/gl/context_egl.cpp + ../duckstation/gl/context_egl_x11.cpp + ../duckstation/gl/context_glx.cpp + ../duckstation/gl/context_egl_wayland.cpp + ../duckstation/gl/x11_window.cpp + + ../glad/glad_egl.c + ../glad/glad_glx.c) + target_link_libraries(melonDS PRIVATE "${X11_LIBRARIES}" "${EGL_LIBRARIES}") + target_include_directories(melonDS PRIVATE "${X11_INCLUDE_DIR}") +endif() + + if (BUILD_STATIC) qt_import_plugins(melonDS INCLUDE Qt::QSvgPlugin) target_link_options(melonDS PRIVATE -static)