This repository was archived by the owner on Jul 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
set(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_SYSTEM_PROCESSOR armv6k) | ||
|
||
# DevkitPro Paths are broken on windows, so we have to fix those | ||
macro(msys_to_cmake_path MsysPath ResultingPath) | ||
string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" ${ResultingPath} "${MsysPath}") | ||
endmacro() | ||
|
||
msys_to_cmake_path("$ENV{DEVKITPRO}" DEVKITPRO) | ||
if(NOT IS_DIRECTORY ${DEVKITPRO}) | ||
message(FATAL_ERROR "Please set DEVKITPRO in your environment") | ||
endif() | ||
|
||
msys_to_cmake_path("$ENV{DEVKITARM}" DEVKITARM) | ||
if(NOT IS_DIRECTORY ${DEVKITARM}) | ||
message(FATAL_ERROR "Please set DEVKITARM in your environment") | ||
endif() | ||
|
||
include(CMakeForceCompiler) | ||
# Prefix detection only works with compiler id "GNU" | ||
# CMake will look for prefixed g++, cpp, ld, etc. automatically | ||
if(WIN32) | ||
CMAKE_FORCE_C_COMPILER("${DEVKITARM}/bin/arm-none-eabi-gcc.exe" GNU) | ||
CMAKE_FORCE_CXX_COMPILER("${DEVKITARM}/bin/arm-none-eabi-g++.exe" GNU) | ||
else() | ||
CMAKE_FORCE_C_COMPILER("${DEVKITARM}/bin/arm-none-eabi-gcc" GNU) | ||
CMAKE_FORCE_CXX_COMPILER("${DEVKITARM}/bin/arm-none-eabi-g++" GNU) | ||
endif() | ||
|
||
set(WITH_PORTLIBS ON CACHE BOOL "use portlibs ?") | ||
|
||
if(WITH_PORTLIBS) | ||
set(CMAKE_FIND_ROOT_PATH ${DEVKITARM} ${DEVKITPRO} ${DEVKITPRO}/portlibs/3ds) | ||
else() | ||
set(CMAKE_FIND_ROOT_PATH ${DEVKITARM} ${DEVKITPRO}) | ||
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) | ||
|
||
SET(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available" ) | ||
SET(DCMAKE_EXE_LINKER_FLAGS "-static") | ||
|
||
add_definitions(-DARM11 -D_3DS) | ||
|
||
set(ARCH "-march=armv6k -mtune=mpcore -mfloat-abi=hard ") | ||
set(CMAKE_C_FLAGS "-fomit-frame-pointer -ffast-math -mword-relocations ${ARCH}" CACHE STRING "C flags") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -std=gnu++11" CACHE STRING "CXX flags") | ||
set(CMAKE_EXE_LINKER_FLAGS "-specs=3dsx.specs ${ARCH}" CACHE STRING "linker flags") | ||
|
||
set(CMAKE_INSTALL_PREFIX ${DEVKITPRO}/portlibs/3ds | ||
CACHE PATH "Install libraries in the portlibs dir") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# - Try to find ctrulib | ||
# Once done this will define | ||
# LIBCTRU_FOUND - System has ctrulib | ||
# LIBCTRU_INCLUDE_DIRS - The ctrulib include directories | ||
# LIBCTRU_LIBRARIES - The libraries needed to use ctrulib | ||
|
||
|
||
# DevkitPro paths are broken on windows, so we have to fix those | ||
macro(msys_to_cmake_path MsysPath ResultingPath) | ||
string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" ${ResultingPath} "${MsysPath}") | ||
endmacro() | ||
|
||
if(NOT ${DEVKITPRO}) | ||
msys_to_cmake_path("$ENV{DEVKITPRO}" DEVKITPRO) | ||
endif() | ||
|
||
set(CTRULIB_PATHS $ENV{CTRULIB} libctru ctrulib ${DEVKITPRO}/libctru ${DEVKITPRO}/ctrulib) | ||
|
||
find_path(LIBCTRU_INCLUDE_DIR 3ds.h | ||
PATHS ${CTRULIB_PATHS} | ||
PATH_SUFFIXES include libctru/include ) | ||
|
||
find_library(LIBCTRU_LIBRARY NAMES ctru libctru.a | ||
PATHS ${CTRULIB_PATHS} | ||
PATH_SUFFIXES lib libctru/lib ) | ||
|
||
set(LIBCTRU_LIBRARIES ${LIBCTRU_LIBRARY} ) | ||
set(LIBCTRU_INCLUDE_DIRS ${LIBCTRU_INCLUDE_DIR} ) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
# handle the QUIETLY and REQUIRED arguments and set LIBCTRU_FOUND to TRUE | ||
# if all listed variables are TRUE | ||
find_package_handle_standard_args(CTRULIB DEFAULT_MSG | ||
LIBCTRU_LIBRARY LIBCTRU_INCLUDE_DIR) | ||
|
||
mark_as_advanced(LIBCTRU_INCLUDE_DIR LIBCTRU_LIBRARY ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
############################################################################ | ||
# Various macros for 3DS homebrews tools | ||
# | ||
# add_shader_library(target input1 [input2 ...]) | ||
# | ||
# /!\ Requires ASM to be enabled ( enable_language(ASM) or project(yourprojectname C CXX ASM) | ||
# | ||
# Convert the shaders listed as input with the picasso assembler, and then creates a library containing the binary arrays of those shaders | ||
# You can then link the 'target' as you would do with any other library. | ||
# Header files containing information about the arrays of binary data are then available for the target linking this library. | ||
# Those header use the same naming convention as devkitArm makefiles : | ||
# A shader named vshader1.pica will generate the header vshader1_pica_shbin.h | ||
# | ||
############################################################################ | ||
get_filename_component(__tools3dsdir ${CMAKE_CURRENT_LIST_FILE} PATH) # Used to locate files to be used with configure_file | ||
|
||
############# | ||
## BIN2S ## | ||
############# | ||
if(NOT BIN2S) | ||
message(STATUS "Looking for bin2s...") | ||
find_program(BIN2S bin2s ${DEVKITARM}/bin) | ||
if(BIN2S) | ||
message(STATUS "bin2s: ${BIN2S} - found") | ||
else(BIN2S) | ||
message(FATAL_ERROR "bin2s - not found") | ||
endif(BIN2S) | ||
endif(NOT BIN2S) | ||
|
||
############# | ||
## PICASSO ## | ||
############# | ||
if(NOT PICASSO_EXE) | ||
message(STATUS "Looking for Picasso...") | ||
find_program(PICASSO_EXE picasso ${DEVKITARM}/bin) | ||
if(PICASSO_EXE) | ||
message(STATUS "Picasso: ${PICASSO_EXE} - found") | ||
set(SHADER_AS picasso CACHE STRING "The shader assembler to be used. Allowed values are 'picasso' or 'nihstro'") | ||
else() | ||
message(FATAL_ERROR "Picasso: ${PICASSO} - not found") | ||
endif() | ||
endif() | ||
|
||
function(generate_shbin OUTPUT INPUT) | ||
if(SHADER_AS STREQUAL "picasso") | ||
add_custom_command(OUTPUT ${OUTPUT} | ||
COMMAND ${PICASSO_EXE} ${OUTPUT} ${INPUT} | ||
) | ||
elseif(SHADER_AS STREQUAL "nihstro") | ||
message(FATAL_ERROR "nihstro not supported yet") | ||
else() | ||
message(FATAL_ERROR "Please set SHADER_AS to 'picasso' or 'nihstro'.") | ||
endif() | ||
endfunction() | ||
|
||
macro(add_shader_library libtarget) | ||
get_cmake_property(ENABLED_LANGUAGES ENABLED_LANGUAGES) | ||
if(NOT ENABLED_LANGUAGES MATCHES ".*ASM.*") | ||
message(FATAL_ERROR "You have to enable ASM in order to use add_shader_library. Use enable_language(ASM). Currently enabled languages are ${ENABLED_LANGUAGES}") | ||
endif() | ||
foreach(__shader_file ${ARGN}) | ||
get_filename_component(__shader_file_wd ${__shader_file} NAME) | ||
string(REGEX REPLACE "^([0-9])" "_\\1" __BIN_FILE_NAME ${__shader_file_wd}) # add '_' if the file name starts by a number | ||
string(REGEX REPLACE "[-./]" "_" __BIN_FILE_NAME ${__BIN_FILE_NAME}) | ||
set(__BIN_FILE_NAME ${__BIN_FILE_NAME}_shbin) | ||
|
||
#Generate the shbin file | ||
list(APPEND __SHADERS_BIN_FILES ${CMAKE_BINARY_DIR}/shaders/${__shader_file_wd}.shbin) | ||
generate_shbin(${CMAKE_BINARY_DIR}/shaders/${__shader_file_wd}.shbin ${__shader_file}) | ||
|
||
#Generate the header file | ||
configure_file(${__tools3dsdir}/bin2s_header.h.in ${CMAKE_BINARY_DIR}/shaders/${__BIN_FILE_NAME}.h) | ||
endforeach() | ||
|
||
# Generate the assembly file, and create the new target | ||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/shaders/shaders.s | ||
PRE_LINK | ||
COMMAND ${BIN2S} ${__SHADERS_BIN_FILES} > ${CMAKE_BINARY_DIR}/shaders/shaders.s | ||
DEPENDS ${__SHADERS_BIN_FILES} | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
) | ||
|
||
add_library(${libtarget} ${CMAKE_BINARY_DIR}/shaders/shaders.s) | ||
target_include_directories(${libtarget} INTERFACE ${CMAKE_BINARY_DIR}/shaders ) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern const u8 @__BIN_FILE_NAME@_end[]; | ||
extern const u8 @__BIN_FILE_NAME@[]; | ||
extern const u32 @__BIN_FILE_NAME@_size; |