From ccf1c43922541c711b1b85c57c7ed19b8662e9ce Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Sun, 18 Aug 2024 18:33:12 -0400 Subject: [PATCH] Don't directly modify the headers included by the melonDS target anymore --- cmake/ConfigureDependencies.cmake | 27 ++------------------------- cmake/ConfigureFeatures.cmake | 2 +- src/libretro/CMakeLists.txt | 3 +++ 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/cmake/ConfigureDependencies.cmake b/cmake/ConfigureDependencies.cmake index 4cc628b2..6243e805 100644 --- a/cmake/ConfigureDependencies.cmake +++ b/cmake/ConfigureDependencies.cmake @@ -2,19 +2,7 @@ include(cmake/libretro-common.cmake) include(cmake/libslirp.cmake) if (HAVE_OPENGL OR HAVE_OPENGLES) - # Upstream melonDS uses GLAD to load OpenGL, but we want to use libretro's loader. - # So instead of patching melonDS, let's change how it's compiled. - - file(GLOB melonDS_cpp_sources - "${melonDS_SOURCE_DIR}/src/*.cpp" - "${melonDS_SOURCE_DIR}/src/ARMJIT_*/*.cpp" - "${melonDS_SOURCE_DIR}/src/frontend/*.cpp" - ) - # Get all C++ source files within melonDS' main directory. - # Need to specify C++ files because melonDS uses assembly, - # which chokes if the glsym headers are included. - - # Now ensure that melonDS can find libretro's headers... + # Ensure that melonDS can find libretro's headers... target_include_directories(core SYSTEM PRIVATE "${libretro-common_SOURCE_DIR}/include") target_include_directories(core PRIVATE "${CMAKE_SOURCE_DIR}/src/libretro") @@ -42,18 +30,7 @@ if (HAVE_OPENGL OR HAVE_OPENGLES) target_include_directories(core SYSTEM PRIVATE "${OpenGLES_V32_INCLUDE_DIR}") endif () - # Ensure that the header that includes GLAD is *excluded* (PLATFORMOGL_H), - # and that melonDS itself uses OpenGL (or OpenGL ES). - target_compile_definitions(core PUBLIC PLATFORMOGL_H OGLRENDERER_ENABLED ENABLE_OGLRENDERER) - - # Now let's include the relevant header before each melonDS C++ source file. - set_source_files_properties( - ${melonDS_cpp_sources} - TARGET_DIRECTORY - core - PROPERTIES - COMPILE_OPTIONS "-include;PlatformOGLPrivate.h") - # TODO: Adapt for GLES2 and GLES3 + target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED ENABLE_OGLRENDERER) endif () add_common_definitions(core) diff --git a/cmake/ConfigureFeatures.cmake b/cmake/ConfigureFeatures.cmake index 7213f15b..ba51810f 100644 --- a/cmake/ConfigureFeatures.cmake +++ b/cmake/ConfigureFeatures.cmake @@ -205,7 +205,7 @@ function(add_common_definitions TARGET) endif () if (HAVE_OPENGL) - target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGL OGLRENDERER_ENABLED CORE ENABLE_OGLRENDERER PLATFORMOGL_H) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGL OGLRENDERER_ENABLED CORE ENABLE_OGLRENDERER) endif () if (HAVE_OPENGL_MODERN) diff --git a/src/libretro/CMakeLists.txt b/src/libretro/CMakeLists.txt index df9ca5c1..d96a6634 100644 --- a/src/libretro/CMakeLists.txt +++ b/src/libretro/CMakeLists.txt @@ -254,6 +254,9 @@ target_compile_definitions(melondsds_libretro PUBLIC STB_IMAGE_STATIC # To avoid using any dynamically-linked STB implementations ) +target_compile_definitions(melondsds_libretro PUBLIC MELONDS_GL_HEADER="PlatformOGLPrivate.h") +target_compile_definitions(core PUBLIC MELONDS_GL_HEADER="PlatformOGLPrivate.h") + target_link_libraries(melondsds_libretro PUBLIC libretro-common core libretro-assets glm::glm pntr fmt::fmt date) if (HAVE_NETWORKING)