mirror of https://github.com/aap/librw.git
cmake+nx: make binary tarball relocatable
This commit is contained in:
parent
03df7307bb
commit
44a619a6e6
|
@ -62,7 +62,7 @@ jobs:
|
|||
conan export cmake/ps2toolchain ps2dev-cmaketoolchain/master@
|
||||
- name: "Download/build dependencies (conan install)"
|
||||
run: |
|
||||
conan install ${{ github.workspace }} librw/master@ -if build -o platform=${{ matrix.platform }} -o gl3_gfxlib=${{ matrix.gl3_gfxlib}} --build missing -pr:h ./host_profile -pr:b default
|
||||
conan install ${{ github.workspace }} librw/master@ -if build -o librw:platform=${{ matrix.platform }} -o librw:gl3_gfxlib=${{ matrix.gl3_gfxlib}} --build missing -pr:h ./host_profile -pr:b default
|
||||
env:
|
||||
CONAN_SYSREQUIRES_MODE: enabled
|
||||
- name: "Build librw (conan build)"
|
||||
|
|
|
@ -13,7 +13,7 @@ jobs:
|
|||
- name: "Build files"
|
||||
run: |
|
||||
/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -S. -Bbuild .. -DLIBRW_PLATFORM=GL3 -DLIBRW_GL3_GFXLIB=GLFW -DLIBRW_INSTALL=True
|
||||
cmake --build build -j
|
||||
cmake --build build --parallel
|
||||
- name: "Create binary package (cpack)"
|
||||
working-directory: ./build
|
||||
run: |
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
project(librw C CXX)
|
||||
project(librw
|
||||
VERSION 0.0.1
|
||||
LANGUAGES C CXX
|
||||
)
|
||||
set(librw_AUTHOR aap)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
if(WIN32)
|
||||
set(LIBRW_PLATFORMS "NULL" "GL3" "D3D9")
|
||||
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL ON)
|
||||
elseif(NINTENDO_SWITCH)
|
||||
set(LIBRW_PLATFORMS "NULL" "GL3")
|
||||
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL OFF)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/nxtoolchain")
|
||||
include(CheckNXFunctions)
|
||||
else()
|
||||
set(LIBRW_PLATFORMS "NULL" "GL3" "PS2")
|
||||
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL ON)
|
||||
endif()
|
||||
set(LIBRW_PLATFORM "NULL" CACHE STRING "Platform")
|
||||
set_property(CACHE LIBRW_PLATFORM PROPERTY STRINGS ${LIBRW_PLATFORMS})
|
||||
|
@ -60,6 +71,19 @@ if(LIBRW_INSTALL)
|
|||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
)
|
||||
|
||||
if(LIBRW_GL3_GFXLIB STREQUAL "SDL2")
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/FindSDL2.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake"
|
||||
)
|
||||
endif()
|
||||
if(NINTENDO_SWITCH)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/nxtoolchain/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)
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()
|
|
@ -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()
|
|
@ -148,7 +148,7 @@ set_target_properties(librw
|
|||
)
|
||||
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
if(NOT NINTENDO_SWITCH)
|
||||
if(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL)
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
|
@ -180,15 +180,10 @@ if(LIBRW_PLATFORM_GL3)
|
|||
endif()
|
||||
|
||||
if(NINTENDO_SWITCH)
|
||||
find_library(SWITCH_EGL_LIBRARY EGL)
|
||||
find_library(SWITCH_GLAPI_LIBRARY glapi)
|
||||
find_library(SWITCH_DRM_NOUVEAU_LIBRARY drm_nouveau)
|
||||
|
||||
find_package(NXGL REQUIRED)
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
${SWITCH_EGL_LIBRARY}
|
||||
${SWITCH_GLAPI_LIBRARY}
|
||||
${SWITCH_DRM_NOUVEAU_LIBRARY}
|
||||
NXGL::OpenGL
|
||||
)
|
||||
endif()
|
||||
elseif(LIBRW_PLATFORM_D3D9)
|
||||
|
|
|
@ -14,10 +14,10 @@ if(LIBRW_INSTALL)
|
|||
endif()
|
||||
|
||||
if(NINTENDO_SWITCH)
|
||||
nx_generate_nacp( dumprwtree.nacp
|
||||
nx_generate_nacp(dumprwtree.nacp
|
||||
NAME "dumprwtree"
|
||||
AUTHOR "aap"
|
||||
VERSION "1.0.0"
|
||||
AUTHOR "${librw_AUTHOR}"
|
||||
VERSION "${librw_VERSION}"
|
||||
)
|
||||
|
||||
nx_create_nro(dumprwtree
|
||||
|
|
|
@ -15,10 +15,10 @@ if(LIBRW_INSTALL)
|
|||
endif()
|
||||
|
||||
if(NINTENDO_SWITCH)
|
||||
nx_generate_nacp( imguitest.nacp
|
||||
nx_generate_nacp(imguitest.nacp
|
||||
NAME "librw imguitest"
|
||||
AUTHOR "aap"
|
||||
VERSION "1.0.0"
|
||||
AUTHOR "${librw_AUTHOR}"
|
||||
VERSION "${librw_VERSION}"
|
||||
)
|
||||
|
||||
nx_create_nro(imguitest
|
||||
|
|
Loading…
Reference in New Issue