cmake: nx toolchain has FindOpenGL module

This commit is contained in:
Anonymous Maarten 2021-06-27 18:43:30 +02:00
parent 60588b7192
commit a20f9e738b
5 changed files with 22 additions and 65 deletions

View File

@ -90,12 +90,6 @@ if(LIBRW_INSTALL)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake"
) )
endif() 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}") string(REPLACE "." ";" cmake_c_compiler_version_list "${CMAKE_C_COMPILER_VERSION}")
list(GET cmake_c_compiler_version_list 0 cmake_c_compiler_version_major) list(GET cmake_c_compiler_version_list 0 cmake_c_compiler_version_major)

View File

@ -3,19 +3,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/librw-targets.cmake")
set(LIBRW_PLATFORM "@LIBRW_PLATFORM@") set(LIBRW_PLATFORM "@LIBRW_PLATFORM@")
set(LIBRW_PLATFORMS "@LIBRW_PLATFORMS@") set(LIBRW_PLATFORMS "@LIBRW_PLATFORMS@")
set(LIBRW_PLATFORM_@LIBRW_PLATFORM@ ON) set(LIBRW_PLATFORM_@LIBRW_PLATFORM@ ON)
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL @LIBRW_PLATFORM_GL3_REQUIRES_OPENGL@)
if(LIBRW_PLATFORM_GL3) if(LIBRW_PLATFORM_GL3)
set(LIBRW_GL3_GFXLIB "@LIBRW_GL3_GFXLIB@") set(LIBRW_GL3_GFXLIB "@LIBRW_GL3_GFXLIB@")
set(LIBRW_GL3_GFXLIBS "@LIBRW_GL3_GFXLIBS@") set(LIBRW_GL3_GFXLIBS "@LIBRW_GL3_GFXLIBS@")
if(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL) set(OpenGL_GL_PREFERENCE GLVND)
set(OpenGL_GL_PREFERENCE GLVND) find_package(OpenGL)
find_package(OpenGL REQUIRED) if(NOT TARGET TARGET OpenGL::OpenGL AND NOT TARGET OpenGL::EGL AND NOT TARGET OpenGL::GL)
endif() message(FATAL_ERROR )
if(NINTENDO_SWITCH)
find_package(NXGL REQUIRED)
endif() endif()
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW") if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
find_package(glfw3 REQUIRED) find_package(glfw3 REQUIRED)
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2") elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2")

View File

@ -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()

View File

@ -45,7 +45,7 @@ class LibrwConan(ConanFile):
def validate(self): def validate(self):
if self.options.platform == "d3d9" and self.settings.os != "Windows": 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._os_is_playstation2:
if self.options.platform not in ("null", "ps2"): if self.options.platform not in ("null", "ps2"):
raise ConanInvalidConfiguration("os=Playstation2 only supports platform=(null,ps2)") raise ConanInvalidConfiguration("os=Playstation2 only supports platform=(null,ps2)")

View File

@ -149,16 +149,6 @@ set_target_properties(librw
) )
if(LIBRW_PLATFORM_GL3) 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") if (LIBRW_GL3_GFXLIB STREQUAL "GLFW")
find_package(glfw3 REQUIRED) find_package(glfw3 REQUIRED)
target_link_libraries(librw target_link_libraries(librw
@ -174,12 +164,25 @@ if(LIBRW_PLATFORM_GL3)
) )
endif() endif()
if(NINTENDO_SWITCH) set(OpenGL_GL_PREFERENCE GLVND)
find_package(NXGL REQUIRED) find_package(OpenGL)
if(TARGET OpenGL::OpenGL)
target_link_libraries(librw target_link_libraries(librw
PRIVATE 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() endif()
elseif(LIBRW_PLATFORM_D3D9) elseif(LIBRW_PLATFORM_D3D9)
target_link_libraries(librw target_link_libraries(librw