From b7f47e9707c905de8bc440e7df0b7491760382af Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Thu, 6 Jul 2023 10:45:35 -0400 Subject: [PATCH] Refactor CMake files - Move all defines based on ConfigureFeatures.cmake into a function - Look for OpenGL ES - Add more defines specific to OpenGL ES --- cmake/ConfigureFeatures.cmake | 117 ++++++++++++++- cmake/FindOpenGLES.cmake | 260 ++++++++++++++++++++++++++++++++++ cmake/libretro-common.cmake | 105 ++++---------- src/libretro/CMakeLists.txt | 60 +------- 4 files changed, 403 insertions(+), 139 deletions(-) create mode 100644 cmake/FindOpenGLES.cmake diff --git a/cmake/ConfigureFeatures.cmake b/cmake/ConfigureFeatures.cmake index 37892ef..124b8cf 100644 --- a/cmake/ConfigureFeatures.cmake +++ b/cmake/ConfigureFeatures.cmake @@ -6,6 +6,8 @@ option(ENABLE_THREADS "Build with thread support, if supported by the target." O option(ENABLE_ZLIB "Build with zlib support, if supported by the target." ON) option(ENABLE_NETWORKING "Build with networking support, if supported by the target." ON) option(ENABLE_DYNAMIC "Build with dynamic library support, if supported by the target." ON) +set(OPENGL_PROFILE OpenGL CACHE STRING "OpenGL profile to use if OpenGL is enabled. Valid values are 'OpenGL' and 'OpenGLES'.") +set_property(CACHE OPENGL_PROFILE PROPERTY STRINGS OpenGL OpenGLES) if (ENABLE_THREADS) find_package(Threads) @@ -25,7 +27,15 @@ endif () if (ENABLE_OGLRENDERER) # ENABLE_OGLRENDERER is defined by melonDS's CMakeLists.txt - find_package(OpenGL) + if (OPENGL_PROFILE STREQUAL "OpenGL") + find_package(OpenGL OPTIONAL_COMPONENTS EGL) + elseif (OPENGL_PROFILE STREQUAL "OpenGLES") + # Built-in support for finding OpenGL ES isn't available until CMake 3.27, + # so we use an external module. + find_package(OpenGLES OPTIONAL_COMPONENTS V1 V2 V3 V31 V32) + else() + message(FATAL_ERROR "Expected an OpenGL profile of 'OpenGL' or 'OpenGLES', got ${OPENGL_PROFILE}") + endif() if (ENABLE_EGL AND OpenGL_EGL_FOUND) set(HAVE_EGL ON) @@ -35,16 +45,33 @@ if (ENABLE_OGLRENDERER) set(HAVE_OPENGL ON) endif() - if (OpenGL::GLES2) + if (OpenGL::GLES2 OR OpenGLES_V1_FOUND) + set(HAVE_OPENGLES ON) + set(HAVE_OPENGLES1 ON) + endif () + + if (OpenGL::GLES2 OR OpenGLES_V2_FOUND) set(HAVE_OPENGLES ON) set(HAVE_OPENGLES2 ON) endif () - if (OpenGL::GLES3) + if (OpenGL::GLES3 OR OpenGLES_V3_FOUND) set(HAVE_OPENGLES ON) set(HAVE_OPENGLES3 ON) endif () + if (OpenGLES_V31_FOUND) + set(HAVE_OPENGLES ON) + set(HAVE_OPENGLES3 ON) + set(HAVE_OPENGLES31 ON) + endif () + + if (OpenGLES_V32_FOUND) + set(HAVE_OPENGLES ON) + set(HAVE_OPENGLES3 ON) + set(HAVE_OPENGLES32 ON) + endif () + check_include_files("GL3/gl3.h;GL3/gl3ext.h" HAVE_OPENGL_MODERN) endif() @@ -75,7 +102,89 @@ if (IOS) set(HAVE_COCOATOUCH ON) endif () +function(add_common_definitions TARGET) + if (APPLE) + target_compile_definitions(${TARGET} PUBLIC GL_SILENCE_DEPRECATION) + # macOS has deprecated OpenGL, and its headers spit out a lot of warnings + endif() + + if (HAVE_COCOATOUCH) + target_compile_definitions(${TARGET} PUBLIC HAVE_COCOATOUCH) + endif () + + if (HAVE_DYNAMIC) + target_compile_definitions(${TARGET} PUBLIC HAVE_DYNAMIC HAVE_DYLIB) + endif () + + if (HAVE_EGL) + target_compile_definitions(${TARGET} PUBLIC HAVE_EGL) + endif () + + if (HAVE_MMAN) + target_compile_definitions(${TARGET} PUBLIC HAVE_MMAN) + endif () + + if (HAVE_MMAP) + target_compile_definitions(${TARGET} PUBLIC HAVE_MMAP) + endif () + + if (HAVE_NETWORKING) + target_compile_definitions(${TARGET} PUBLIC HAVE_NETWORKING) + + if (HAVE_GETADDRINFO) + target_compile_definitions(${TARGET} PUBLIC HAVE_GETADDRINFO) + endif () + + if (HAVE_SOCKET_LEGACY) + target_compile_definitions(${TARGET} PUBLIC HAVE_SOCKET_LEGACY) + endif () + endif () + + if (HAVE_OPENGL) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGL OGLRENDERER_ENABLED CORE ENABLE_OGLRENDERER PLATFORMOGL_H) + endif () + + if (HAVE_OPENGL_MODERN) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGL_MODERN) + endif () + + if (HAVE_OPENGLES) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGLES) + endif () + + if (HAVE_OPENGLES1) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGLES1 HAVE_OPENGLES_1) + endif () + + if (HAVE_OPENGLES2) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGLES2 HAVE_OPENGLES_2) + endif () + + if (HAVE_OPENGLES3) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGLES3 HAVE_OPENGLES_3) + endif () + + if (HAVE_OPENGLE31) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGLES31 HAVE_OPENGLES_31 HAVE_OPENGLES_3_1) + endif () + + if (HAVE_OPENGLE32) + target_compile_definitions(${TARGET} PUBLIC HAVE_OPENGLES32 HAVE_OPENGLES_32 HAVE_OPENGLES_3_2) + endif () + + if (HAVE_STRL) + target_compile_definitions(${TARGET} PUBLIC HAVE_STRL) + endif () + + if (HAVE_THREADS) + target_compile_definitions(${TARGET} PUBLIC HAVE_THREADS) + endif () + + if (HAVE_ZLIB) + target_compile_definitions(${TARGET} PUBLIC HAVE_ZLIB) + endif () +endfunction() + # TODO: Detect if ARM NEON is available; if so, define HAVE_NEON and HAVE_ARM_NEON_ASM_OPTIMIZATIONS # TODO: Detect if libnx is available and we're building for Switch; if so, define HAVE_LIBNX -# TODO: Detect if OpenGL ES is available; if so, define HAVE_OPENGLES(_?[123](_[12])?)? # TODO: Detect if SSL is available; if so, define HAVE_SSL \ No newline at end of file diff --git a/cmake/FindOpenGLES.cmake b/cmake/FindOpenGLES.cmake new file mode 100644 index 0000000..e024df8 --- /dev/null +++ b/cmake/FindOpenGLES.cmake @@ -0,0 +1,260 @@ +# Copyright 2020-2021 Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# +# Original Author: +# 2020-2021, Ryan Pavlik + +#[[.rst: +FindOpenGLES +--------------- + +Find the OpenGL ES graphics API. + +Components +^^^^^^^^^^ + +The following components are supported: + +* ``V1`` - OpenGL ES 1 (including emulation on OpenGL ES 2) +* ``V2`` - OpenGL ES 2 +* ``V3`` - OpenGL ES 3 +* ``V31` - OpenGL ES 3.1 - same as 3 but checking also for gl31.h +* ``V32` - OpenGL ES 3.2 - same as 3 but checking also for gl32.h + +If none are specified, the default is ``V2``. + +Targets +^^^^^^^ + +If successful, some subset of the following imported targets are created. + +* ``OpenGLES::OpenGLESv1`` +* ``OpenGLES::OpenGLESv2`` +* ``OpenGLES::OpenGLESv3`` +* ``OpenGLES::OpenGLESv31`` +* ``OpenGLES::OpenGLESv32`` + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variable may also be set to assist/control the operation of this module: + +``OpenGLES_ROOT_DIR`` + The root to search for OpenGLES. +#]] + +set(OpenGLES_ROOT_DIR + "${OpenGLES_ROOT_DIR}" + CACHE PATH "Root to search for OpenGLES") + +if(NOT OpenGLES_FIND_COMPONENTS) + set(OpenGLES_FIND_COMPONENTS V2) +endif() + +if(NOT ANDROID) + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + set(_old_prefix_path "${CMAKE_PREFIX_PATH}") + # So pkg-config uses OpenGLES_ROOT_DIR too. + if(OpenGLES_ROOT_DIR) + list(APPEND CMAKE_PREFIX_PATH ${OpenGLES_ROOT_DIR}) + endif() + pkg_check_modules(PC_glesv1_cm QUIET glesv1_cm) + pkg_check_modules(PC_glesv2 QUIET glesv2) + # Restore + set(CMAKE_PREFIX_PATH "${_old_prefix_path}") + endif() +endif() + +find_path( + OpenGLES_V1_INCLUDE_DIR + NAMES GLES/gl.h + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${PC_glesv2_INCLUDE_DIRS} ${PC_glesv1_cm_INCLUDE_DIRS} + PATH_SUFFIXES include) +find_path( + OpenGLES_V2_INCLUDE_DIR + NAMES GLES2/gl2.h + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${PC_glesv2_INCLUDE_DIRS} ${PC_glesv1_cm_INCLUDE_DIRS} + PATH_SUFFIXES include) +find_path( + OpenGLES_V3_INCLUDE_DIR + NAMES GLES3/gl3.h + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${OpenGLES_V1_INCLUDE_DIR} ${OpenGLES_V2_INCLUDE_DIR} + ${PC_glesv2_INCLUDE_DIRS} ${PC_glesv1_cm_INCLUDE_DIRS} + PATH_SUFFIXES include) +find_path( + OpenGLES_V31_INCLUDE_DIR + NAMES GLES3/gl31.h + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${OpenGLES_V1_INCLUDE_DIR} ${OpenGLES_V2_INCLUDE_DIR} + ${OpenGLES_V3_INCLUDE_DIR} ${PC_glesv2_INCLUDE_DIRS} + ${PC_glesv1_cm_INCLUDE_DIRS} + PATH_SUFFIXES include) +find_path( + OpenGLES_V32_INCLUDE_DIR + NAMES GLES3/gl32.h + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${OpenGLES_V1_INCLUDE_DIR} ${OpenGLES_V2_INCLUDE_DIR} + ${OpenGLES_V3_INCLUDE_DIR} ${OpenGLES_V31_INCLUDE_DIR} + ${PC_glesv2_INCLUDE_DIRS} ${PC_glesv1_cm_INCLUDE_DIRS} + PATH_SUFFIXES include) + +find_library( + OpenGLES_V1_LIBRARY + NAMES GLES GLESv1_CM + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${PC_glesv1_cm_LIBRARY_DIRS} + PATH_SUFFIXES lib) +find_library( + OpenGLES_V2_LIBRARY + NAMES GLESv2 OpenGLES # for Apple framework + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${PC_glesv2_LIBRARY_DIRS} + PATH_SUFFIXES lib) +find_library( + OpenGLES_V3_LIBRARY + NAMES GLESv3 + PATHS ${OpenGLES_ROOT_DIR} + HINTS ${PC_glesv2_LIBRARY_DIRS} + PATH_SUFFIXES lib) + +if(OpenGLES_V2_LIBRARY AND NOT OpenGLES_V3_LIBRARY) + set(OpenGLES_V3_LIBRARY ${OpenGLES_V2_LIBRARY}) +endif() + +set(_gles_required_vars) +foreach(_comp IN LISTS OpenGLES_FIND_COMPONENTS) + if(_comp STREQUAL "V1") + list(APPEND _gles_required_vars OpenGLES_V1_LIBRARY + OpenGLES_V1_INCLUDE_DIR) + if(OpenGLES_V1_INCLUDE_DIR AND OpenGLES_V1_LIBRARY) + set(OpenGLES_${_comp}_FOUND TRUE) + else() + set(OpenGLES_${_comp}_FOUND FALSE) + endif() + elseif(_comp STREQUAL "V2") + list(APPEND _gles_required_vars OpenGLES_V2_LIBRARY + OpenGLES_V2_INCLUDE_DIR) + if(OpenGLES_V2_INCLUDE_DIR AND OpenGLES_V2_LIBRARY) + set(OpenGLES_${_comp}_FOUND TRUE) + else() + set(OpenGLES_${_comp}_FOUND FALSE) + endif() + elseif(_comp STREQUAL "V3") + list(APPEND _gles_required_vars OpenGLES_V3_LIBRARY + OpenGLES_V3_INCLUDE_DIR) + if(OpenGLES_V3_INCLUDE_DIR AND OpenGLES_V3_LIBRARY) + set(OpenGLES_${_comp}_FOUND TRUE) + else() + set(OpenGLES_${_comp}_FOUND FALSE) + endif() + elseif(_comp STREQUAL "V31") + list(APPEND _gles_required_vars OpenGLES_V3_LIBRARY + OpenGLES_V31_INCLUDE_DIR) + + if(OpenGLES_V31_INCLUDE_DIR AND OpenGLES_V3_LIBRARY) + set(OpenGLES_${_comp}_FOUND TRUE) + else() + set(OpenGLES_${_comp}_FOUND FALSE) + endif() + elseif(_comp STREQUAL "V32") + list(APPEND _gles_required_vars OpenGLES_V3_LIBRARY + OpenGLES_V32_INCLUDE_DIR) + if(OpenGLES_V32_INCLUDE_DIR AND OpenGLES_V3_LIBRARY) + set(OpenGLES_${_comp}_FOUND TRUE) + else() + set(OpenGLES_${_comp}_FOUND FALSE) + endif() + else() + message( + WARNING "${_comp} is not a recognized OpenGL-ES component/version") + set(OpenGLES_${_comp}_FOUND FALSE) + endif() +endforeach() +if(_gles_required_vars) + list(REMOVE_DUPLICATES _gles_required_vars) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + OpenGLES + REQUIRED_VARS ${_gles_required_vars} + HANDLE_COMPONENTS) +if(OpenGLES_FOUND) + if(OpenGLES_V1_FOUND AND NOT TARGET OpenGLES::OpenGLESv1) + add_library(OpenGLES::OpenGLESv1 SHARED IMPORTED) + + set_target_properties( + OpenGLES::OpenGLESv1 + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${OpenGLES_V1_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OpenGLES_V1_LIBRARY}) + endif() + if(OpenGLES_V2_FOUND AND NOT TARGET OpenGLES::OpenGLESv2) + add_library(OpenGLES::OpenGLESv2 SHARED IMPORTED) + + set_target_properties( + OpenGLES::OpenGLESv2 + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${OpenGLES_V2_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OpenGLES_V2_LIBRARY}) + endif() + if(OpenGLES_V3_FOUND) + if(NOT TARGET OpenGLES::OpenGLESv3) + add_library(OpenGLES::OpenGLESv3 SHARED IMPORTED) + + set_target_properties( + OpenGLES::OpenGLESv3 + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${OpenGLES_V3_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OpenGLES_V3_LIBRARY}) + endif() + if(OpenGLES_V31_FOUND AND NOT TARGET OpenGLES::OpenGLESv31) + add_library(OpenGLES::OpenGLESv31 SHARED IMPORTED) + + set_target_properties( + OpenGLES::OpenGLESv31 + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${OpenGLES_V31_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OpenGLES_V3_LIBRARY}) + endif() + if(OpenGLES_V32_FOUND AND NOT TARGET OpenGLES::OpenGLESv32) + add_library(OpenGLES::OpenGLESv32 SHARED IMPORTED) + + set_target_properties( + OpenGLES::OpenGLESv32 + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${OpenGLES_V32_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OpenGLES_V3_LIBRARY}) + endif() + endif() + mark_as_advanced( + OpenGLES_V1_LIBRARY + OpenGLES_V1_INCLUDE_DIR + OpenGLES_V2_LIBRARY + OpenGLES_V2_INCLUDE_DIR + OpenGLES_V3_LIBRARY + OpenGLES_V3_INCLUDE_DIR + OpenGLES_V31_INCLUDE_DIR + OpenGLES_V32_INCLUDE_DIR) +endif() +mark_as_advanced(OpenGLES_ROOT_DIR) + +include(FeatureSummary) +set_package_properties( + OpenGLES PROPERTIES + URL "https://www.khronos.org/opengles/" + DESCRIPTION + "A cross-platform graphics API, specialized for mobile and embedded, defined as a subset of desktop OpenGL." +) diff --git a/cmake/libretro-common.cmake b/cmake/libretro-common.cmake index 0b2fdbe..9e619bd 100644 --- a/cmake/libretro-common.cmake +++ b/cmake/libretro-common.cmake @@ -61,31 +61,10 @@ target_sources(libretro-common PRIVATE ${libretro-common_SOURCE_DIR}/vfs/vfs_implementation.c ) -if (HAVE_THREADS) - target_sources(libretro-common PRIVATE - ${libretro-common_SOURCE_DIR}/rthreads/rthreads.c - ) +add_common_definitions(libretro-common) - target_compile_definitions(libretro-common PUBLIC HAVE_THREADS) -endif () - -if (NOT HAVE_STRL) - target_sources(libretro-common PRIVATE - ${libretro-common_SOURCE_DIR}/compat/compat_strl.c - ) -else () - target_compile_definitions(libretro-common PUBLIC HAVE_STRL) -endif () - -if (HAVE_OPENGL) - target_sources(libretro-common PRIVATE - ${libretro-common_SOURCE_DIR}/glsm/glsm.c - ${libretro-common_SOURCE_DIR}/glsym/rglgen.c - ${libretro-common_SOURCE_DIR}/glsym/glsym_gl.c - ) - - target_compile_definitions(libretro-common PUBLIC HAVE_OPENGL OGLRENDERER_ENABLED CORE) - target_link_libraries(libretro-common PUBLIC OpenGL::GL) +if (HAVE_EGL) + target_link_libraries(libretro-common PUBLIC OpenGL::EGL) endif () if (HAVE_NETWORKING) @@ -95,59 +74,45 @@ if (HAVE_NETWORKING) ${libretro-common_SOURCE_DIR}/net/net_http_parse.c ${libretro-common_SOURCE_DIR}/net/net_socket.c ) - - target_compile_definitions(libretro-common PUBLIC HAVE_NETWORKING) - - if (HAVE_GETADDRINFO) - target_compile_definitions(libretro-common PUBLIC HAVE_GETADDRINFO) - endif () - - if (HAVE_SOCKET_LEGACY) - target_compile_definitions(libretro-common PUBLIC HAVE_SOCKET_LEGACY) - endif () endif () -if (HAVE_OPENGL_MODERN) - target_compile_definitions(libretro-common PUBLIC HAVE_OPENGL_MODERN) -endif () +if (HAVE_OPENGL) + target_sources(libretro-common PRIVATE + ${libretro-common_SOURCE_DIR}/glsm/glsm.c + ${libretro-common_SOURCE_DIR}/glsym/rglgen.c + ${libretro-common_SOURCE_DIR}/glsym/glsym_gl.c + ) -if (HAVE_OPENGLES) - target_compile_definitions(libretro-common PUBLIC HAVE_OPENGLES) -endif () - -if (HAVE_OPENGLES3) - target_compile_definitions(libretro-common PUBLIC HAVE_OPENGLES3) - target_compile_definitions(libretro-common PUBLIC HAVE_OPENGLES_3) + target_link_libraries(libretro-common PUBLIC OpenGL::GL) + target_include_directories(libretro-common PUBLIC ${OPENGL_INCLUDE_DIR}) endif () if (HAVE_OPENGLES2) - target_compile_definitions(libretro-common PUBLIC HAVE_OPENGLES2) - target_compile_definitions(libretro-common PUBLIC HAVE_OPENGLES_2) -endif () - -if (HAVE_EGL) - target_compile_definitions(libretro-common PUBLIC HAVE_EGL) - target_link_libraries(libretro-common PUBLIC OpenGL::EGL) -endif () - -if (HAVE_STRL) - target_compile_definitions(libretro-common PUBLIC HAVE_STRL) -else () target_sources(libretro-common PRIVATE + ${libretro-common_SOURCE_DIR}/glsym/glsym_es2.c + ) +endif () + +if (HAVE_OPENGLES3) + target_sources(libretro-common PRIVATE + ${libretro-common_SOURCE_DIR}/glsym/glsym_es3.c + ) +endif () + +if (NOT HAVE_STRL) + target_sources(libretro-common PRIVATE + ${libretro-common_SOURCE_DIR}/compat/compat_strl.c ${libretro-common_SOURCE_DIR}/compat/compat_strldup.c - ) + ) endif () -if (HAVE_MMAP) - target_compile_definitions(libretro-common PUBLIC HAVE_MMAP) -endif () - -if (HAVE_MMAN) - target_compile_definitions(libretro-common PUBLIC HAVE_MMAN) +if (HAVE_THREADS) + target_sources(libretro-common PRIVATE + ${libretro-common_SOURCE_DIR}/rthreads/rthreads.c + ) endif () if (HAVE_ZLIB) - target_compile_definitions(libretro-common PUBLIC HAVE_ZLIB) target_sources(libretro-common PRIVATE ${libretro-common_SOURCE_DIR}/file/archive_file_zlib.c ${libretro-common_SOURCE_DIR}/streams/trans_stream_zlib.c @@ -155,20 +120,8 @@ if (HAVE_ZLIB) target_link_libraries(libretro-common PUBLIC ZLIB::ZLIB) endif () -if (HAVE_DYNAMIC) - target_compile_definitions(libretro-common PUBLIC HAVE_DYNAMIC HAVE_DYLIB) -endif () - -if (HAVE_COCOATOUCH) - target_compile_definitions(libretro-common PUBLIC HAVE_COCOATOUCH) -endif () - set_target_properties(libretro-common PROPERTIES PREFIX "" OUTPUT_NAME "libretro-common") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(libretro-common PRIVATE -fPIC) target_link_options(libretro-common PRIVATE -fPIC) endif () - -if (APPLE) - target_compile_definitions(libretro-common PUBLIC GL_SILENCE_DEPRECATION) -endif() \ No newline at end of file diff --git a/src/libretro/CMakeLists.txt b/src/libretro/CMakeLists.txt index cde20a3..aa927ca 100644 --- a/src/libretro/CMakeLists.txt +++ b/src/libretro/CMakeLists.txt @@ -45,66 +45,16 @@ target_include_directories(libretro SYSTEM PUBLIC "${melonDS_SOURCE_DIR}/src" ) -if (HAVE_STRL) - target_compile_definitions(libretro PUBLIC HAVE_STRL) -endif () - -if (HAVE_THREADS) - target_compile_definitions(libretro PUBLIC HAVE_THREADS) -endif () +add_common_definitions(libretro) if (HAVE_OPENGL) if (APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-framework,OpenGL") endif () target_sources(libretro PRIVATE opengl.cpp) - target_compile_definitions(libretro PUBLIC HAVE_OPENGL OGLRENDERER_ENABLED ENABLE_OGLRENDERER PLATFORMOGL_H) target_link_libraries(libretro PUBLIC OpenGL::GL) endif () -if (HAVE_OPENGL_MODERN) - target_compile_definitions(libretro PUBLIC HAVE_OPENGL_MODERN) -endif () - -if (HAVE_OPENGLES3) - target_compile_definitions(libretro PUBLIC HAVE_OPENGLES3) - target_compile_definitions(libretro PUBLIC HAVE_OPENGLES_3) -endif () - -if (HAVE_OPENGLES2) - target_compile_definitions(libretro PUBLIC HAVE_OPENGLES2) - target_compile_definitions(libretro PUBLIC HAVE_OPENGLES_2) -endif () - -if (HAVE_MMAP) - target_compile_definitions(libretro PUBLIC HAVE_MMAP) -endif() - -if (HAVE_MMAN) - target_compile_definitions(libretro PUBLIC HAVE_MMAN) -endif() - -if (HAVE_NETWORKING) - target_compile_definitions(libretro PUBLIC HAVE_NETWORKING) - - if (HAVE_SOCKET_LEGACY) - target_compile_definitions(libretro PUBLIC HAVE_SOCKET_LEGACY) - endif () - - if (HAVE_GETADDRINFO) - target_compile_definitions(libretro PUBLIC HAVE_GETADDRINFO) - endif () -endif () - -if (HAVE_EGL) - target_compile_definitions(libretro PUBLIC HAVE_EGL) -endif () - -if (APPLE) - target_compile_definitions(libretro PUBLIC GL_SILENCE_DEPRECATION) - # macOS has deprecated OpenGL, and its headers spit out a lot of warnings -endif() - if (ENABLE_JIT) target_compile_definitions(libretro PUBLIC JIT_ENABLED HAVE_JIT ENABLE_JIT) # TODO: Disable on certain platforms @@ -114,14 +64,6 @@ if (ENABLE_JIT) endif () endif () -if (HAVE_DYNAMIC) - target_compile_definitions(libretro PUBLIC HAVE_DYNAMIC HAVE_DYLIB) -endif () - -if (HAVE_COCOATOUCH) - target_compile_definitions(libretro PUBLIC HAVE_COCOATOUCH) -endif () - set_target_properties(libretro PROPERTIES PREFIX "" OUTPUT_NAME "melondsds_libretro") if (APPLE)