cmake+nx: make binary tarball relocatable

This commit is contained in:
Anonymous Maarten
2021-06-17 23:44:07 +02:00
committed by Adrian Graber
parent 03df7307bb
commit 44a619a6e6
9 changed files with 89 additions and 19 deletions

View File

@@ -3,13 +3,19 @@ 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@")
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
if(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
endif()
if(NINTENDO_SWITCH)
find_package(NXGL REQUIRED)
endif()
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
find_package(glfw3 REQUIRED)
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2")

View File

@@ -0,0 +1,7 @@
if(NOT COMMAND nx_generate_nacp)
message(FATAL_ERROR "The `nx_generate_nacp` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()
if(NOT COMMAND nx_create_nro)
message(FATAL_ERROR "The `nx_create_nro` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()

View File

@@ -0,0 +1,38 @@
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()