summaryrefslogtreecommitdiffstats
path: root/cmake/nx/NXFunctions.cmake
blob: f67b3ebcf8d0e0b8abc0d97c6a6d4ca13c6bc77b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if(NOT COMMAND nx_generate_nacp)
    message(FATAL_ERROR "The `nx_generate_nacp` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()

if(NOT COMMAND nx_create_nro)
    message(FATAL_ERROR "The `nx_create_nro` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()

set(CMAKE_EXECUTABLE_SUFFIX ".elf")

function(reVC_platform_target TARGET)
    cmake_parse_arguments(RPT "INSTALL" "" "" ${ARGN})

    get_target_property(TARGET_TYPE "${TARGET}" TYPE)
    if(TARGET_TYPE STREQUAL "EXECUTABLE")
        nx_generate_nacp(${TARGET}.nacp
            NAME "${TARGET}"
            AUTHOR "${${PROJECT}_AUTHOR}"
            VERSION "1.0.0-${GIT_SHA1}"
        )

        nx_create_nro(${TARGET}
            NACP ${TARGET}.nacp
            ICON "${PROJECT_SOURCE_DIR}/res/images/logo_256.jpg"
        )

        if(${PROJECT}_INSTALL AND RPT_INSTALL)
            get_target_property(TARGET_OUTPUT_NAME ${TARGET} OUTPUT_NAME)
            if(NOT TARGET_OUTPUT_NAME)
                set(TARGET_OUTPUT_NAME "${TARGET}")
            endif()

            install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_OUTPUT_NAME}.nro"
                DESTINATION "."
            )
        endif()
    endif()
endfunction()