Skip to content

Commit

Permalink
Don't directly modify the headers included by the melonDS target anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseTG committed Aug 18, 2024
1 parent 216aa57 commit ccf1c43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
27 changes: 2 additions & 25 deletions cmake/ConfigureDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/ConfigureFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/libretro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ccf1c43

Please sign in to comment.