-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
72 lines (57 loc) · 3.06 KB
/
CMakeLists.txt
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
cmake_minimum_required(VERSION 3.21)
project(subsdk CXX C ASM)
## Error if not using switch toolchain file
if (NOT SWITCH)
message(FATAL_ERROR "Not targeting switch, make sure to specify -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake")
endif ()
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
## Title Id
set(TITLE_ID 0100000000010000)
set(CONFIG_TITLE_ID 0x${TITLE_ID})
## Target subsdk
set(SUBSDKX subsdk9)
add_compile_definitions(EXL_PROGRAM_ID=${CONFIG_TITLE_ID} NNSDK=1)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/module/${SUBSDKX}.json.template ${CMAKE_CURRENT_BINARY_DIR}/${SUBSDKX}.json)
## Libraries
#include_directories(${PROJECT_SOURCE_DIR}/lib/example) # Add your lib directory here
## Game headers
include_directories(${PROJECT_SOURCE_DIR}/include/aarch64)
include_directories(${PROJECT_SOURCE_DIR}/include/agl)
include_directories(${PROJECT_SOURCE_DIR}/include/al)
include_directories(${PROJECT_SOURCE_DIR}/include/game)
include_directories(${PROJECT_SOURCE_DIR}/include/sead)
include_directories(${PROJECT_SOURCE_DIR}/include/NintendoSDK)
## Project sources
include_directories(${PROJECT_SOURCE_DIR}/src/program)
include_directories(${PROJECT_SOURCE_DIR}/src/lib)
include_directories(${PROJECT_SOURCE_DIR}/src)
file(GLOB_RECURSE SOURCES_ASM ${PROJECT_SOURCE_DIR}/src/*.s ${PROJECT_SOURCE_DIR}/lib/*.s)
file(GLOB_RECURSE SOURCES_H ${PROJECT_SOURCE_DIR}/src/*.h ${PROJECT_SOURCE_DIR}/src/*.hpp ${PROJECT_SOURCE_DIR}/lib/*.h ${PROJECT_SOURCE_DIR}/lib/*.hpp)
file(GLOB_RECURSE SOURCES_CXX ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.c ${PROJECT_SOURCE_DIR}/lib/*.cpp ${PROJECT_SOURCE_DIR}/lib/*.c)
file(GLOB_RECURSE LOCAL_LIBRARIES ${PROJECT_SOURCE_DIR}/lib/*.a)
## Include nx tools
include(${CMAKE_SOURCE_DIR}/cmake/SwitchTools.cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
## ${SUBSDKX}
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
#set_source_files_properties(${SOURCES_CXX} PROPERTIES LANGUAGE CXX)
add_executable(${SUBSDKX} ${SOURCES_ASM} ${SOURCES_C} ${SOURCES_H} ${SOURCES_CXX} ${IMGUI_SOURCES})
add_compile_definitions(EXL_LOAD_KIND=Module EXL_LOAD_KIND_ENUM=EXL_LOAD_KIND_MODULE)
target_link_libraries(${SUBSDKX} ${LOCAL_LIBRARIES})
# generate header file for imgui shader binary
# target_embed_binaries(${SUBSDKX} "${PROJECT_SOURCE_DIR}/imgui.bin")
## Prepare subsdk ld
set(SUBSDK_LD_PATH ${CMAKE_CURRENT_SOURCE_DIR}/module/${SUBSDKX}.ld)
execute_process(COMMAND uname OUTPUT_VARIABLE uname)
if (uname MATCHES "^MINGW")
string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" SUBSDK_LD_PATH "${SUBSDK_LD_PATH}")
endif ()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/module/${SUBSDKX}.specs.template ${CMAKE_CURRENT_BINARY_DIR}/${SUBSDKX}.specs)
## Build nso & generate npdm
add_nso_target_subsdk(${SUBSDKX})
set_target_properties(${SUBSDKX} PROPERTIES CONFIG_JSON "${CMAKE_CURRENT_BINARY_DIR}/${SUBSDKX}.json")
__generate_npdm(${SUBSDKX})
set_target_properties(${SUBSDKX} PROPERTIES LINK_FLAGS "-specs ${CMAKE_BINARY_DIR}/${SUBSDKX}.specs -g3 ${ARCH} -nostartfiles -nostdlib")
add_custom_target(${SUBSDKX}_meta DEPENDS create_npdm ${SUBSDKX}_nso)