Skip to content

CMake toolchain for Nintendo Switch homebrew development

License

Notifications You must be signed in to change notification settings

xvk-64/switch-cmake

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

switch-cmake

Extensible CMake toolchain for Nintendo Switch homebrew development with devkitA64 and libnx.

Table of Contents

Introduction

This project aims to provide a CMake toolchain for Nintendo Switch homebrew development using devkitA64 and libnx. It is intended as an alternative to the makefile-based system currently provided with the tools.

Why CMake

[TODO]

Quick Start

Prerequisites

First, make sure you have installed the latest release of devkitA64, the Nintendo Switch homebrew development kit provided by devkitPro. Follow the installation guide here.

Important: Make sure that the devkitPro environment variables have been configured properly. CMake will use these to locate the devkitA64 tools. Specifically, the ${DEVKITPRO} variable should point to the devkitPro installation directory.

You'll also need to have CMake.


Building the examples

To build the template examples, clone this repository and open a terminal in the root directory. Make a build directory with:

$ mkdir build

Next, have CMake configure the project and generate build files with:

$ cmake -G "Unix Makefiles" --toolchain=DevkitA64Libnx.cmake -S . -B build

The -G "Unix Makefiles" argument specifies which generator CMake will use. In this case, CMake will output Makefiles when the project is built.

The --toolchain=DevkitA64Libnx.cmake argument specifies which toolchain file CMake will use. This will configure CMake to use the DevkitPro environment and compilers.

Finally, build the project with

$ cmake --build build

You should now have a my_app.nro executable in the ./build/templates/application/ directory.


Running the examples

Running your homebrew on your Nintendo Switch is easy when netloading with nxlink, which is packaged with devkitA64.

Important: Your Switch needs to be running the Atmosphère custom firmware with hbmenu installed. Please also make sure the Switch is connected to the same wireless network as your computer.

On your Nintendo Switch, open the Gallery applet to start hbmenu, then press Y to start the netloader.

In the repository's root directory, run the following command to upload and run the executable:

$ nxlink ./build/templates/application/my_app.nro

If nxlink fails with the message No response from Switch!, try supplying the Switch's IP address via the -a <IP> argument.

When the executable finishes uploading, you should see a Hello World! message in the top left of your Switch's display.

Switch Homebrew

File Formats

devkitPro Ecosystem

devkitA64

portlibs

libnx

CMake Files

FindLibnx.cmake

FindLibTwili.cmake

FindMbedTLS.cmake

SwitchTools.cmake

Templates

Application

Library

System Module

About

CMake toolchain for Nintendo Switch homebrew development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CMake 85.9%
  • C 14.1%