-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
83 lines (64 loc) · 2.74 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
73
74
75
76
77
78
79
80
81
82
83
cmake_minimum_required(VERSION 3.24)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/ARMCC.cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT DEFINED ENV{ARMCC_PATH})
message(FATAL_ERROR "please set ARMCC_PATH")
endif()
find_program(ARM_ASM NAMES armasm.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_AR NAMES armar.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_CC NAMES armcc.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_LINK NAMES armlink.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH)
# find_program(ARM_FROMELF NAMES fromelf.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH) # not important
add_subdirectory(Library/nnsdk)
add_subdirectory(Library/sead)
add_subdirectory(Library/LibMessageStudio)
macro (set_compilers)
set(CMAKE_CXX_COMPILER_ID ARMCC)
set(CMAKE_AR ${ARM_AR})
set(CMAKE_C_COMPILER ${ARM_CC})
set(CMAKE_CXX_COMPILER ${ARM_CC})
set(CMAKE_ASM_COMPILER ${ARM_ASM})
set(CMAKE_LINKER ${ARM_LINK})
endmacro()
if (WIN32)
set_compilers()
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_ASM_COMPILER_WORKS TRUE)
endif()
project(RedPepper C CXX ASM)
if (NOT WIN32)
set_compilers()
endif()
set(CMAKE_EXECUTABLE_SUFFIX ".axf")
__compiler_armcc(C)
__compiler_armcc(CXX)
__compiler_armcc(ASM)
file(GLOB_RECURSE csourcefiles "Source/*.c")
file(GLOB_RECURSE cxxsourcefiles "Source/*.cpp")
add_executable(RedPepper ${csourcefiles} ${cxxsourcefiles})
target_link_libraries(RedPepper PUBLIC
nnsdk
sead
LibMessageStudio
)
target_link_options(RedPepper PUBLIC
--cpu=MPCore --entry=__ctr_start --startup=__ctr_start --library_type=standardlib
--ref_cpp_init --scanlib --legacyalign
--tailreorder --no_remove --datacompressor=off --arm_only
--inline
--verbose --mangled --symbols --paged
--scatter=${CMAKE_CURRENT_BINARY_DIR}/Linker.ld
)
target_compile_options(RedPepper PUBLIC $<$<COMPILE_LANGUAGE:CXX>:
--apcs=//interwork --cpu=MPCore --fpmode=fast --cpp --arm --force_new_nothrow
--signed_chars --multibyte-chars --locale=japanese --no_vfe # workaround, vfe should be enabled
--no_rtti_data --no_rtti --no_exceptions -O3 -Otime --data-reorder --split_sections --forceinline
>)
target_compile_options(RedPepper PUBLIC $<$<COMPILE_LANGUAGE:C>:
--apcs=//interwork --cpu=MPCore --fpmode=fast --c99 --arm
--signed_chars --multibyte-chars --locale=japanese
-Otime --data-reorder --split_sections
>)
target_compile_definitions(RedPepper PUBLIC NON_MATCHING=)
target_include_directories(RedPepper PUBLIC ${CMAKE_SOURCE_DIR}/Include)