CMake for 3ds homebrews

Discussion in '3DS - Homebrew Development and Emulators' started by Lectem, Sep 1, 2015.

  1. Lectem

    Lectem Member

    Nov 21, 2014
    Hi folks,
    I made some cmake scripts a few weeks ago, with those you can easily port cmake projects to devkitpro with only minor changes.

    The repo url is

    The reason I'm sharing it here is that I'd like people to use the same scripts instead of baking their own, so that it will be easier to maintain those in the future.

    A quick example of its functionnalities :

    cmake_minimum_required(VERSION 2.8)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DKA_SUGGESTED_C_FLAGS}") # Use the devkitArm suggested flags. This is not mandatory.
    # Note that you must copy the cmake folder and the DevkitArm3DS.cmake file in this directory
    list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) # Add the cmake folder to the modules paths, so that we can use the tools and find_package for ctrulib
    include(Tools3DS) # Include all the macros and tools needed for 3ds development.
    find_package(CTRULIB REQUIRED) # Look for ctrulib
    add_executable(hello_world source/main.c) # Create the elf file
    target_link_libraries(hello_world ${LIBCTRU_LIBRARIES}) # Link ctrulib
    target_include_directories(hello_world PUBLIC ${LIBCTRU_INCLUDE_DIRS}) # Add the ctrulib include folder
    add_3dsx_target(hello_world) # Generate the .3dsx and .smdh from the hello_world target
    Hope it will help some people around here !
    hippy dave likes this.
  2. hippy dave

    hippy dave BBMB

    Apr 30, 2012
    United Kingdom
    Cool thanks, I've encountered projects using cmake and this should be helpful :)
Quick Reply
Draft saved Draft deleted