-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
97 lines (79 loc) · 3.78 KB
/
Copy pathCMakeLists.txt
File metadata and controls
97 lines (79 loc) · 3.78 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cmake_minimum_required(VERSION 3.15)
# Option to select target platform
if(NOT DEFINED PLATFORM)
if(DEFINED SWITCH)
set(PLATFORM "SWITCH")
elseif(DEFINED WIIU)
set(PLATFORM "WIIU")
elseif(DEFINED CEMU)
set(PLATFORM "CEMU")
else()
message(STATUS "No PLATFORM specified. Defaulting to SWITCH (Use -DPLATFORM=SWITCH, -DPLATFORM=WIIU, or -DPLATFORM=CEMU)")
set(PLATFORM "SWITCH")
endif()
endif()
if(PLATFORM STREQUAL "CEMU" OR PLATFORM STREQUAL "WIIU")
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_C_COMPILER powerpc-eabi-gcc)
set(CMAKE_CXX_COMPILER powerpc-eabi-g++)
endif()
project(WiiXLaunch C CXX ASM)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Automatically synchronize master wiixlaunch.json into build/generated/
execute_process(
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_config.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE CONFIG_GEN_RESULT
)
# Include directories: Order matters! build/generated/include shadows vendor/exlaunch headers cleanly
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/build/generated/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)
# Optional WiiXLaunch modules (e.g. vendor/wiixlaunch-botw) - not part of
# base WiiXLaunch, picked up automatically if this mod added one as a
# submodule (git submodule add <url> vendor/wiixlaunch-<name>).
file(GLOB WIIXL_MODULE_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/vendor/wiixlaunch-*/include")
include_directories(${WIIXL_MODULE_INCLUDE_DIRS})
if(PLATFORM STREQUAL "SWITCH")
message(STATUS "Building WiiXLaunch for Nintendo Switch (ARM64)")
add_compile_definitions(__SWITCH__=1 WIIXL_SWITCH=1)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/vendor/exlaunch/source
)
file(GLOB_RECURSE SOURCES "src/*.cpp")
add_executable(wiixlaunch_switch ${SOURCES})
target_link_libraries(wiixlaunch_switch PRIVATE)
elseif(PLATFORM STREQUAL "WIIU")
# A .wps is an elf2rpl-processed RPL linked against wut/WUPS with their
# specs and linker script - CMake has no rules for any of that, so this
# target lives in the WUPS Makefile flow instead (scripts/wiiu/Makefile,
# driven by build_wiiu.bat). Erroring here beats silently producing a
# shared library that isn't a loadable plugin.
message(FATAL_ERROR "The Wii U target is not built with CMake - run build_wiiu.bat (WUPS Makefile flow, see scripts/wiiu/Makefile).")
elseif(PLATFORM STREQUAL "CEMU")
message(STATUS "Building WiiXLaunch for Cemu Code Cave (PowerPC)")
add_compile_definitions(__CEMU__=1 WIIXL_CEMU=1)
# -fno-pie -fno-pic, NOT -fPIE: see build_cemu.bat (the script actually
# used for this target) for the full explanation.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-pie -fno-pic -msdata=none")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-pie -fno-pic -msdata=none")
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -T ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cemu.ld -Wl,-q")
file(GLOB_RECURSE SOURCES "src/*.cpp")
set(TARGET_CEMU wiixlaunch_cemu)
add_executable(${TARGET_CEMU} ${SOURCES})
add_custom_command(TARGET ${TARGET_CEMU} POST_BUILD
COMMAND powerpc-eabi-objcopy -O binary --set-section-flags .bss=alloc,load,contents $<TARGET_FILE:${TARGET_CEMU}> ${CMAKE_BINARY_DIR}/payload.bin
COMMENT "Extracting raw binary for Cemu Graphic Pack..."
)
else()
message(FATAL_ERROR "Unknown PLATFORM: ${PLATFORM}. Must be SWITCH, WIIU, or CEMU.")
endif()
# Post-build deployment step
add_custom_target(deploy
COMMAND ${CMAKE_COMMAND} -E echo "Running WiiXLaunch Deployment Packager..."
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/deploy.py
COMMENT "Packaging build artifacts into deploy/ folder..."
)