Add Nintendo Switch support through CMake

This commit is contained in:
Adrian Graber 2021-06-09 23:52:51 +02:00
parent 5b4f91b161
commit 7301893152
3 changed files with 46 additions and 6 deletions

26
.github/workflows/build-switch.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Build for Nintendo Switch using CMake provided by devkitPro
on:
pull_request:
push:
release:
types: published
jobs:
build-nintendo-switch:
runs-on: ubuntu-latest
container: devkitpro/devkita64:latest
steps:
- uses: actions/checkout@v2
- 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
- name: "Create binary package (cpack)"
working-directory: ./build
run: |
cpack
- name: "Archive binary package (github artifacts)"
uses: actions/upload-artifact@v2
with:
name: "switch-gl3"
path: build/*.tar.xz
if-no-files-found: error

View File

@ -100,6 +100,8 @@ if(LIBRW_INSTALL)
set(os "-apple") set(os "-apple")
elseif(UNIX) elseif(UNIX)
set(os "-linux") set(os "-linux")
elseif(NINTENDO_SWITCH)
set(os "-switch")
else() else()
set(compiler "-UNK") set(compiler "-UNK")
message(WARNING "Unknown os. Created cpack package will be wrong. (override using cpack -P)") message(WARNING "Unknown os. Created cpack package will be wrong. (override using cpack -P)")

View File

@ -148,6 +148,7 @@ set_target_properties(librw
) )
if(LIBRW_PLATFORM_GL3) if(LIBRW_PLATFORM_GL3)
if(NOT NINTENDO_SWITCH)
set(OpenGL_GL_PREFERENCE GLVND) set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
@ -155,6 +156,8 @@ if(LIBRW_PLATFORM_GL3)
PUBLIC PUBLIC
OpenGL::GL 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
@ -175,6 +178,15 @@ if(LIBRW_PLATFORM_GL3)
) )
endif() endif()
endif() endif()
if(NINTENDO_SWITCH)
target_link_libraries(librw
PUBLIC
EGL
glapi
drm_nouveau
)
endif()
elseif(LIBRW_PLATFORM_D3D9) elseif(LIBRW_PLATFORM_D3D9)
target_link_libraries(librw target_link_libraries(librw
PUBLIC PUBLIC