From a20f9e738bbf79ec2a815859d96e0054ef844f61 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 27 Jun 2021 18:43:30 +0200 Subject: [PATCH] cmake: nx toolchain has FindOpenGL module --- CMakeLists.txt | 6 ------ cmake/librw-config.cmake.in | 12 +++++------- cmake/nx/FindNXGL.cmake | 38 ------------------------------------- conanfile.py | 2 +- src/CMakeLists.txt | 29 +++++++++++++++------------- 5 files changed, 22 insertions(+), 65 deletions(-) delete mode 100644 cmake/nx/FindNXGL.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f6b64..de3211d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,12 +90,6 @@ if(LIBRW_INSTALL) DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake" ) endif() - if(NINTENDO_SWITCH) - install( - FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/nx/FindNXGL.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake" - ) - endif() string(REPLACE "." ";" cmake_c_compiler_version_list "${CMAKE_C_COMPILER_VERSION}") list(GET cmake_c_compiler_version_list 0 cmake_c_compiler_version_major) diff --git a/cmake/librw-config.cmake.in b/cmake/librw-config.cmake.in index 6ea7619..519e63e 100644 --- a/cmake/librw-config.cmake.in +++ b/cmake/librw-config.cmake.in @@ -3,19 +3,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/librw-targets.cmake") set(LIBRW_PLATFORM "@LIBRW_PLATFORM@") set(LIBRW_PLATFORMS "@LIBRW_PLATFORMS@") set(LIBRW_PLATFORM_@LIBRW_PLATFORM@ ON) -set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL @LIBRW_PLATFORM_GL3_REQUIRES_OPENGL@) if(LIBRW_PLATFORM_GL3) set(LIBRW_GL3_GFXLIB "@LIBRW_GL3_GFXLIB@") set(LIBRW_GL3_GFXLIBS "@LIBRW_GL3_GFXLIBS@") - if(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL) - set(OpenGL_GL_PREFERENCE GLVND) - find_package(OpenGL REQUIRED) - endif() - if(NINTENDO_SWITCH) - find_package(NXGL REQUIRED) + set(OpenGL_GL_PREFERENCE GLVND) + find_package(OpenGL) + if(NOT TARGET TARGET OpenGL::OpenGL AND NOT TARGET OpenGL::EGL AND NOT TARGET OpenGL::GL) + message(FATAL_ERROR ) endif() + if(LIBRW_GL3_GFXLIB STREQUAL "GLFW") find_package(glfw3 REQUIRED) elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2") diff --git a/cmake/nx/FindNXGL.cmake b/cmake/nx/FindNXGL.cmake deleted file mode 100644 index 25e86d2..0000000 --- a/cmake/nx/FindNXGL.cmake +++ /dev/null @@ -1,38 +0,0 @@ -find_library(NXGL_EGL_LIBRARY EGL) -find_library(NXGL_GLAPI_LIBRARY glapi) -find_library(NXGL_DRM_NOUVEAU_LIBRARY drm_nouveau) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(NXGL - REQUIRED_VARS NXGL_EGL_LIBRARY NXGL_GLAPI_LIBRARY NXGL_DRM_NOUVEAU_LIBRARY -) - -if(NXGL_FOUND) - if(NOT TARGET NXGL::EGL) - add_library(NXGL::EGL UNKNOWN IMPORTED) - set_target_properties(NXGL::EGL PROPERTIES - IMPORTED_LOCATION "${NXGL_EGL_LIBRARY}" - ) - endif() - - if(NOT TARGET NXGL::glapi) - add_library(NXGL::glapi UNKNOWN IMPORTED) - set_target_properties(NXGL::glapi PROPERTIES - IMPORTED_LOCATION "${NXGL_GLAPI_LIBRARY}" - ) - endif() - - if(NOT TARGET NXGL::drm_nouveau) - add_library(NXGL::drm_nouveau UNKNOWN IMPORTED) - set_target_properties(NXGL::drm_nouveau PROPERTIES - IMPORTED_LOCATION "${NXGL_DRM_NOUVEAU_LIBRARY}" - ) - endif() - - if(NOT TARGET NXGL::OpenGL) - add_library(NXGL::OpenGL INTERFACE IMPORTED) - set_target_properties(NXGL::OpenGL PROPERTIES - INTERFACE_LINK_LIBRARIES "NXGL::EGL;NXGL::glapi;NXGL::drm_nouveau" - ) - endif() -endif() diff --git a/conanfile.py b/conanfile.py index 9f72e08..4cefb49 100644 --- a/conanfile.py +++ b/conanfile.py @@ -45,7 +45,7 @@ class LibrwConan(ConanFile): def validate(self): if self.options.platform == "d3d9" and self.settings.os != "Windows": - raise ConanInvalidConfiguration("d3d9 can only be built for Windows") + raise ConanInvalidConfiguration("platform=d3d9 can only be built for os=Windows") if self._os_is_playstation2: if self.options.platform not in ("null", "ps2"): raise ConanInvalidConfiguration("os=Playstation2 only supports platform=(null,ps2)") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bdfefc7..5b16901 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -149,16 +149,6 @@ set_target_properties(librw ) if(LIBRW_PLATFORM_GL3) - if(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL) - set(OpenGL_GL_PREFERENCE GLVND) - find_package(OpenGL REQUIRED) - - target_link_libraries(librw - PRIVATE - OpenGL::GL - ) - endif() - if (LIBRW_GL3_GFXLIB STREQUAL "GLFW") find_package(glfw3 REQUIRED) target_link_libraries(librw @@ -174,12 +164,25 @@ if(LIBRW_PLATFORM_GL3) ) endif() - if(NINTENDO_SWITCH) - find_package(NXGL REQUIRED) + set(OpenGL_GL_PREFERENCE GLVND) + find_package(OpenGL) + if(TARGET OpenGL::OpenGL) target_link_libraries(librw PRIVATE - NXGL::OpenGL + OpenGL::OpenGL ) + elseif(TARGET OpenGL::EGL) + target_link_libraries(librw + PRIVATE + OpenGL::EGL + ) + elseif(TARGET OpenGL::GL) + target_link_libraries(librw + PRIVATE + OpenGL::GL + ) + else() + message(FATAL_ERROR "find_package(OpenGL) failed.") endif() elseif(LIBRW_PLATFORM_D3D9) target_link_libraries(librw