diff --git a/cmake/libnx.cmake b/cmake/libnx.cmake new file mode 100644 index 00000000..7aa57555 --- /dev/null +++ b/cmake/libnx.cmake @@ -0,0 +1,66 @@ +# Copied from https://github.com/vbe0201/switch-cmake/blob/master/devkita64-libnx.cmake +# Copyright (c) 2019 SwitchPy Team +# Licensed under MIT license, full text is available in COPYING +if (NOT DEFINED ENV{DEVKITPRO}) + cmake_panic("Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +endif () + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(SWITCH TRUE) # To be used for multiplatform projects + +# devkitPro paths are broken on Windows. We need to use this macro to fix those. +macro(msys_to_cmake_path msys_path resulting_path) + if (WIN32) + string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" ${resulting_path} ${msys_path}) + else () + set(${resulting_path} ${msys_path}) + endif () +endmacro() + +msys_to_cmake_path($ENV{DEVKITPRO} DEVKITPRO) +set(DEVKITA64 ${DEVKITPRO}/devkitA64) +set(LIBNX ${DEVKITPRO}/libnx) +set(PORTLIBS_PATH ${DEVKITPRO}/portlibs) +set(PORTLIBS ${PORTLIBS_PATH}/switch) + +set(TOOLCHAIN_PREFIX ${DEVKITA64}/bin/aarch64-none-elf-) +if (WIN32) + set(TOOLCHAIN_SUFFIX ".exe") +else () + set(TOOLCHAIN_SUFFIX "") +endif () + +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc${TOOLCHAIN_SUFFIX}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++${TOOLCHAIN_SUFFIX}) +set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}as${TOOLCHAIN_SUFFIX}) + +set(PKG_CONFIG_EXECUTABLE ${TOOLCHAIN_PREFIX}pkg-config${TOOLCHAIN_SUFFIX}) +set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar${TOOLCHAIN_SUFFIX} CACHE STRING "") +set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib${TOOLCHAIN_SUFFIX} CACHE STRING "") +set(CMAKE_LD "/${TOOLCHAIN_PREFIX}ld${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "") +set(CMAKE_OBJCOPY "${TOOLCHAIN_PREFIX}objcopy${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "") +set(CMAKE_SIZE_UTIL "${TOOLCHAIN_PREFIX}size${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "") + +set(WITH_PORTLIBS ON CACHE BOOL "use portlibs ?") +if (WITH_PORTLIBS) + set(CMAKE_FIND_ROOT_PATH ${DEVKITA64} ${DEVKITPRO} ${LIBNX} ${PORTLIBS}) +else () + set(CMAKE_FIND_ROOT_PATH ${DEVKITA64} ${DEVKITPRO} ${LIBNX}) +endif () + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +add_definitions(-D__SWITCH__) +set(ARCH "-march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MP -g -Wall -O2 -ffunction-sections ${ARCH}") +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${ARCH} -ftls-model=local-exec -L${LIBNX}/lib -L${PORTLIBS}/lib") +set(CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT}) + +set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available") +set(CMAKE_INSTALL_PREFIX ${PORTLIBS}) +set(CMAKE_PREFIX_PATH ${PORTLIBS}) diff --git a/libretro-buildbot-recipe.sh b/libretro-buildbot-recipe.sh index fe929fee..e14a36e3 100755 --- a/libretro-buildbot-recipe.sh +++ b/libretro-buildbot-recipe.sh @@ -387,6 +387,7 @@ build_libretro_generic_makefile() { 3ds|ctr ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/ctr.cmake" ;; vita ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/vita.cmake" ;; psp|psp1 ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/psp1.cmake" ;; + libnx ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/libnx.cmake" ;; * ) EXTRAARGS="" ;; esac diff --git a/recipes/nintendo/libnx b/recipes/nintendo/libnx index eae1c351..3a89a070 100644 --- a/recipes/nintendo/libnx +++ b/recipes/nintendo/libnx @@ -70,6 +70,7 @@ stella libretro-stella https://github.com/stella-emu/stella.git master YES GENER test libretro-samples https://github.com/libretro/libretro-samples.git master YES GENERIC Makefile tests/test tgbdual libretro-tgbdual https://github.com/libretro/tgbdual-libretro.git master YES GENERIC Makefile . theodore libretro-theodore https://github.com/Zlika/theodore.git master YES GENERIC Makefile . +tic80 libretro-tic80 https://github.com/nesbox/TIC-80.git master YES CMAKE Makefile builddir -DBUILD_PLAYER=OFF -DBUILD_SOKOL=OFF -DBUILD_SDL=OFF -DBUILD_DEMO_CARTS=OFF -DBUILD_LIBRETRO=ON -DDISABLE_NETWORKING=ON -DLIBRETRO_STATIC=ON -DLIBRETRO_SUFFIX=_libnx tyrquake libretro-tyrquake https://github.com/libretro/tyrquake.git master YES GENERIC Makefile . fbneo libretro-fbneo https://github.com/libretro/FBNeo.git master YES GENERIC Makefile src/burner/libretro uzem libretro-uzem https://github.com/libretro/libretro-uzem.git master NO GENERIC Makefile . diff --git a/recipes/nintendo/libnx.conf b/recipes/nintendo/libnx.conf index 9af5f28e..a01e21c9 100644 --- a/recipes/nintendo/libnx.conf +++ b/recipes/nintendo/libnx.conf @@ -8,6 +8,6 @@ RA YES JOBS 4 CORE_JOB YES MAKE make - +CMAKE cmake