mirror of https://github.com/libAthena/athena.git
parent
488acc8675
commit
5306525029
@ -0,0 +1,3 @@ |
||||
set(CMAKE_EXECUTABLE_SUFFIX ".nro.so") |
||||
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) |
||||
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "/usr/bin/llvm-mc ${AS_FLAGS} <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>") |
@ -0,0 +1,174 @@ |
||||
|
||||
get_filename_component(__tools_switch_sdir ${CMAKE_CURRENT_LIST_FILE} PATH) # Used to locate files to be used with configure_file |
||||
|
||||
############# |
||||
## ELF2NRO ## |
||||
############# |
||||
if (NOT ELF2NRO) |
||||
# message(STATUS "Looking for makerom...") |
||||
find_program(ELF2NRO elf2nro ${DEVKITPRO}/tools/bin) |
||||
if (ELF2NRO) |
||||
message(STATUS "elf2nro: ${ELF2NRO} - found") |
||||
else () |
||||
message(WARNING "elf2nro - not found") |
||||
endif () |
||||
endif () |
||||
|
||||
############# |
||||
## ELF2KIP ## |
||||
############# |
||||
if (NOT ELF2KIP) |
||||
# message(STATUS "Looking for makerom...") |
||||
find_program(ELF2KIP elf2kip ${DEVKITPRO}/tools/bin) |
||||
if (ELF2KIP) |
||||
message(STATUS "elf2kip: ${ELF2KIP} - found") |
||||
else () |
||||
message(WARNING "elf2kip - not found") |
||||
endif () |
||||
endif () |
||||
############# |
||||
## ELF2NSO ## |
||||
############# |
||||
if (NOT ELF2NSO) |
||||
# message(STATUS "Looking for makerom...") |
||||
find_program(ELF2NSO elf2nso ${DEVKITPRO}/tools/bin) |
||||
if (ELF2NSO) |
||||
message(STATUS "elf2nso: ${ELF2NSO} - found") |
||||
else () |
||||
message(WARNING "elf2nso - not found") |
||||
endif () |
||||
endif () |
||||
|
||||
############# |
||||
## BIN2S ## |
||||
############# |
||||
if (NOT BIN2S) |
||||
# message(STATUS "Looking for bin2s...") |
||||
find_program(BIN2S bin2s ${DEVKITPRO}/tools/bin) |
||||
if (BIN2S) |
||||
message(STATUS "bin2s: ${BIN2S} - found") |
||||
else () |
||||
message(WARNING "bin2s - not found") |
||||
endif () |
||||
endif () |
||||
|
||||
############# |
||||
## RAW2C ## |
||||
############# |
||||
if (NOT RAW2C) |
||||
# message(STATUS "Looking for bin2s...") |
||||
find_program(RAW2C raw2c ${DEVKITPRO}/tools/bin) |
||||
if (RAW2C) |
||||
message(STATUS "raw2c: ${RAW2C} - found") |
||||
else () |
||||
message(WARNING "raw2c - not found") |
||||
endif () |
||||
endif () |
||||
|
||||
################## |
||||
## BUILD_PFS0 ## |
||||
################## |
||||
if (NOT BUILD_PFS0) |
||||
# message(STATUS "Looking for bin2s...") |
||||
find_program(BUILD_PFS0 build_pfs0 ${DEVKITPRO}/tools/bin) |
||||
if (BUILD_PFS0) |
||||
message(STATUS "build_pfs0: ${BUILD_PFS0} - found") |
||||
else () |
||||
message(WARNING "build_pfs0 - not found") |
||||
endif () |
||||
endif () |
||||
|
||||
################ |
||||
## NACPTOOL ## |
||||
################ |
||||
if (NOT NACPTOOL) |
||||
# message(STATUS "Looking for bin2s...") |
||||
find_program(NACPTOOL nacptool ${DEVKITPRO}/tools/bin) |
||||
if (NACPTOOL) |
||||
message(STATUS "nacptool: ${NACPTOOL} - found") |
||||
else () |
||||
message(WARNING "nacptool - not found") |
||||
endif () |
||||
endif () |
||||
|
||||
|
||||
function(__add_nacp target APP_TITLE APP_AUTHOR APP_VERSION) |
||||
set(__NACP_COMMAND ${NACPTOOL} --create ${APP_TITLE} ${APP_AUTHOR} ${APP_VERSION} ${CMAKE_CURRENT_BINARY_DIR}/${target}) |
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target} |
||||
COMMAND ${__NACP_COMMAND} |
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} |
||||
VERBATIM |
||||
) |
||||
endfunction() |
||||
function(add_nro_target target) |
||||
get_filename_component(target_we ${target} NAME_WE) |
||||
if ((NOT (${ARGC} GREATER 1 AND "${ARGV1}" STREQUAL "NO_NACP")) OR (${ARGC} GREATER 3)) |
||||
if (${ARGC} GREATER 3) |
||||
set(APP_TITLE ${ARGV1}) |
||||
set(APP_AUTHOR ${ARGV2}) |
||||
set(APP_VERSION ${ARGV3}) |
||||
endif () |
||||
if (${ARGC} EQUAL 5) |
||||
set(APP_ICON ${ARGV4}) |
||||
endif () |
||||
if (NOT APP_TITLE) |
||||
set(APP_TITLE ${target}) |
||||
endif () |
||||
if (NOT APP_AUTHOR) |
||||
set(APP_AUTHOR "Unspecified Author") |
||||
endif () |
||||
if (NOT APP_VERSION) |
||||
set(APP_VERSION "1.0") |
||||
endif () |
||||
if (NOT APP_ICON) |
||||
if (EXISTS ${target}.png) |
||||
set(APP_ICON ${target}.png) |
||||
elseif (EXISTS icon.png) |
||||
set(APP_ICON icon.png) |
||||
elseif (NX) |
||||
set(APP_ICON ${DEVKITPRO}/libnx/default_icon.png) |
||||
else () |
||||
message(FATAL_ERROR "No icon found ! Please use NO_SMDH or provide some icon.") |
||||
endif () |
||||
endif () |
||||
if (NOT ${target_we}.nacp) |
||||
__add_nacp(${target_we}.nacp ${APP_TITLE} ${APP_AUTHOR} ${APP_VERSION}) |
||||
endif () |
||||
if (CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
||||
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro |
||||
COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> --icon=${APP_ICON} --nacp=${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro |
||||
DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp |
||||
VERBATIM |
||||
) |
||||
else () |
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro |
||||
COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> --icon=${APP_ICON} --nacp=${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro |
||||
DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp |
||||
VERBATIM |
||||
) |
||||
endif () |
||||
else () |
||||
message(STATUS "No nacp file will be generated") |
||||
if (CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
||||
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro |
||||
COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro |
||||
DEPENDS ${target} |
||||
VERBATIM |
||||
) |
||||
else () |
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro |
||||
COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro |
||||
DEPENDS ${target} |
||||
VERBATIM |
||||
) |
||||
endif () |
||||
|
||||
endif () |
||||
if (CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
||||
add_custom_target(${target_we}_nro ALL SOURCES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro) |
||||
|
||||
else () |
||||
add_custom_target(${target_we}_nro ALL SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro) |
||||
endif () |
||||
endfunction() |
@ -0,0 +1,71 @@ |
||||
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6) |
||||
find_package(PythonInterp 3 REQUIRED) |
||||
|
||||
set(CONVERTER "${LIBTRN}/tools/elf2nxo.py") |
||||
|
||||
function(add_nro_target target) |
||||
get_filename_component(target_we ${target} NAME_WE) |
||||
if ((NOT (${ARGC} GREATER 1 AND "${ARGV1}" STREQUAL "NO_HDR")) OR (${ARGC} GREATER 3)) |
||||
if (${ARGC} GREATER 3) |
||||
set(APP_TITLE ${ARGV1}) |
||||
set(APP_AUTHOR ${ARGV2}) |
||||
set(APP_VERSION ${ARGV3}) |
||||
endif () |
||||
if (${ARGC} EQUAL 5) |
||||
set(APP_ICON ${ARGV4}) |
||||
endif () |
||||
if (NOT APP_TITLE) |
||||
set(APP_TITLE ${target}) |
||||
endif () |
||||
if (NOT APP_AUTHOR) |
||||
set(APP_AUTHOR "Unspecified Author") |
||||
endif () |
||||
if (NOT APP_VERSION) |
||||
set(APP_VERSION "1.0") |
||||
endif () |
||||
if (NOT APP_ICON) |
||||
if (EXISTS ${target}.png) |
||||
set(APP_ICON ${target}.png) |
||||
elseif (EXISTS icon.png) |
||||
set(APP_ICON icon.png) |
||||
else () |
||||
message(FATAL_ERROR "No icon found ! Please use NO_SMDH or provide some icon.") |
||||
endif () |
||||
endif () |
||||
if (CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
||||
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro |
||||
COMMAND ${PYTHON_EXECUTABLE} ${CONVERTER} -n ${APP_TITLE} -d ${APP_AUTHOR} -v ${APP_VERSION} -i ${APP_ICON} $<TARGET_FILE:${target}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro nro |
||||
DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp |
||||
VERBATIM |
||||
) |
||||
else () |
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro |
||||
COMMAND ${PYTHON_EXECUTABLE} ${CONVERTER} -n ${APP_TITLE} -d ${APP_AUTHOR} -v ${APP_VERSION} -i ${APP_ICON} $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro nro |
||||
DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp |
||||
VERBATIM |
||||
) |
||||
endif () |
||||
else () |
||||
message(STATUS "No header will be generated") |
||||
if (CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
||||
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro |
||||
COMMAND ${PYTHON_EXECUTABLE} ${CONVERTER} $<TARGET_FILE:${target}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro nro |
||||
DEPENDS ${target} |
||||
VERBATIM |
||||
) |
||||
else () |
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro |
||||
COMMAND ${PYTHON_EXECUTABLE} ${CONVERTER} $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro nro |
||||
DEPENDS ${target} |
||||
VERBATIM |
||||
) |
||||
endif () |
||||
|
||||
endif () |
||||
if (CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
||||
add_custom_target(${target_we}_nro ALL SOURCES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro) |
||||
|
||||
else () |
||||
add_custom_target(${target_we}_nro ALL SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro) |
||||
endif () |
||||
endfunction() |
@ -0,0 +1,51 @@ |
||||
set(CMAKE_SYSTEM_NAME "Switch") |
||||
set(CMAKE_CXX_STANDARD 11) |
||||
set(CMAKE_C_STANDARD 11) |
||||
set(WITH_PORTLIBS ON CACHE BOOL "use portlibs ?") |
||||
|
||||
macro(msys_to_cmake_path MsysPath ResultingPath) |
||||
if(WIN32) |
||||
string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" ${ResultingPath} "${MsysPath}") |
||||
else() |
||||
set(${ResultingPath} "${MsysPath}") |
||||
endif() |
||||
endmacro() |
||||
|
||||
msys_to_cmake_path("$ENV{DEVKITPRO}" DEVKITPRO) |
||||
|
||||
set(NX 1) |
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") |
||||
include(SwitchTools_nx) |
||||
|
||||
if(WIN32) |
||||
set(CMAKE_C_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc.exe") |
||||
set(CMAKE_CXX_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++.exe") |
||||
set(CMAKE_AR "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ar.exe" CACHE STRING "") |
||||
set(CMAKE_RANLIB "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ranlib.exe" CACHE STRING "") |
||||
else() |
||||
set(CMAKE_C_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc") |
||||
set(CMAKE_CXX_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++") |
||||
set(CMAKE_AR "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ar" CACHE STRING "") |
||||
set(CMAKE_RANLIB "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ranlib" CACHE STRING "") |
||||
endif() |
||||
|
||||
set(PKG_CONFIG "${DEVKITPRO}/portlibs/bin/aarch64-none-elf-pkg-config" CACHE STRING "") |
||||
set(CPPFLAGS "-D__SWITCH__ -D__USE_LARGEFILE64=1 -D__USE_LARGEOFFSET64=1 -I${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include") |
||||
set(CMAKE_C_FLAGS "${CPPFLAGS} -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ffunction-sections" CACHE STRING "C flags") |
||||
set(CMAKE_CXX_FLAGS "${CPPFLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -std=gnu++11" CACHE STRING "C++ flags") |
||||
|
||||
if(WITH_PORTLIBS) |
||||
set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO}/devkitA64 ${DEVKITPRO} ${DEVKITPRO}/libnx ${DEVKITPRO}/portlibs/switch) |
||||
else() |
||||
set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO}/devkitA64 ${DEVKITPRO}/libnx ${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(CMAKE_STATIC_LINKER_FLAGS_INIT "-march=armv8-a -mtune=cortex-a57 -mtp=soft -L${DEVKITPRO}/libnx/lib -L${DEVKITPRO}/portlibs/switch/lib") |
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-specs=${DEVKITPRO}/libnx/switch.specs -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -L${DEVKITPRO}/libnx/lib -L${DEVKITPRO}/portlibs/switch/lib") |
||||
|
||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available") |
||||
set(CMAKE_INSTALL_PREFIX ${DEVKITPRO}/portlibs/switch) |
Loading…
Reference in new issue