-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathToolchain.cmake
108 lines (106 loc) · 6.35 KB
/
Toolchain.cmake
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
98
99
100
101
102
103
104
105
106
107
# setup toolchains
if (PLATFORM_LINUX)
set(CMAKE_SYSTEM_NAME "Linux" CACHE STRING "" FORCE)
set(CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "" FORCE)
set(TARGET_PLATFORM linux CACHE STRING "" FORCE)
elseif (PLATFORM_WINDOWS)
set(CMAKE_SYSTEM_NAME Windows CACHE STRING "" FORCE)
set(CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "" FORCE)
set(TARGET_PLATFORM windows CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__WINDOWS__" CACHE STRING "C flags" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__WINDOWS__" CACHE STRING "CXX flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static" CACHE STRING "" FORCE)
elseif (PLATFORM_SWITCH)
if (DEFINED ENV{DEVKITPRO})
set(TARGET_PLATFORM switch CACHE STRING "target platform" FORCE)
set(DEVKITPRO $ENV{DEVKITPRO} CACHE STRING "DEVKITPRO" FORCE)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${DEVKITPRO}/cmake/Switch.cmake" CACHE PATH "toolchain file")
endif ()
else ()
message(FATAL_ERROR "Please define DEVKITPRO to point to your SDK path!")
endif ()
elseif (PLATFORM_3DS)
if (DEFINED ENV{DEVKITPRO})
set(TARGET_PLATFORM 3ds CACHE STRING "target platform" FORCE)
set(DEVKITPRO $ENV{DEVKITPRO} CACHE STRING "DEVKITPRO" FORCE)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${DEVKITPRO}/cmake/3DS.cmake" CACHE PATH "toolchain file")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} -L${DEVKITPRO}/portlibs/3ds/lib -L${DEVKITPRO}/libctru/lib" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_INIT} CACHE STRING "" FORCE)
endif ()
else ()
message(FATAL_ERROR "Please define DEVKITPRO to point to your SDK path!")
endif ()
elseif (PLATFORM_VITA)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if (NOT DEFINED ENV{VITASDK})
set(ENV{VITASDK} "/usr/local/vitasdk")
endif ()
set(TARGET_PLATFORM vita CACHE STRING "" FORCE)
set(VITASDK $ENV{VITASDK} CACHE STRING "VITASDK" FORCE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
endif ()
elseif (PLATFORM_PS4)
if (DEFINED ENV{OPENORBIS})
set(TARGET_PLATFORM ps4 CACHE STRING "target platform" FORCE)
set(OPENORBIS $ENV{OPENORBIS} CACHE STRING "OPENORBIS" FORCE)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${OPENORBIS}/cmake/ps4.cmake" CACHE PATH "toolchain file")
endif ()
else ()
message(FATAL_ERROR "Please define OPENORBIS to point to your SDK path!")
endif ()
elseif (PLATFORM_PS3)
if (NOT DEFINED ENV{PS3DEV})
set(ENV{PS3DEV} "/usr/local/ps3dev")
endif ()
set(PS3DEV $ENV{PS3DEV} CACHE STRING "PS3DEV" FORCE)
set(PSL1GHT ${PS3DEV} CACHE STRING "PSL1GHT" FORCE)
set(ENV{PSL1GHT} ${PSL1GHT})
set(TARGET_PLATFORM ps3 CACHE STRING "" FORCE)
SET(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR "powerpc64")
set(CMAKE_C_COMPILER "${PSL1GHT}/ppu/bin/ppu-gcc")
set(CMAKE_CXX_COMPILER "${PSL1GHT}/ppu/bin/ppu-g++")
set(CMAKE_ASM_COMPILER "${PSL1GHT}/ppu/bin/ppu-gcc")
set(CMAKE_C_FLAGS "-O2 -mcpu=cell -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections -I${PSL1GHT}/ppu/include -I${PSL1GHT}/portlibs/ppu/include" CACHE STRING "C flags" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu++11 -fpermissive" CACHE STRING "C++ flags" FORCE)
set(CMAKE_C_LINK_FLAGS "-L${PSL1GHT}/ppu/lib -L${PSL1GHT}/portlibs/ppu/lib " CACHE STRING "" FORCE)
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_C_LINK_FLAGS}" CACHE STRING "" FORCE)
elseif (PLATFORM_DREAMCAST)
set(TARGET_PLATFORM dreamcast CACHE STRING "" FORCE)
set(CMAKE_SYSTEM_NAME "Generic")
set(CMAKE_SYSTEM_PROCESSOR "sh")
set(SH_ELF_PREFIX /opt/toolchains/dc/sh-elf)
set(KOS_BASE $ENV{KOS_BASE} CACHE STRING "" FORCE)
set(KOS_ARCH "dreamcast" CACHE STRING "" FORCE)
set(KOS_SUBARCH "pristine" CACHE STRING "" FORCE)
set(KOS_AS "${SH_ELF_PREFIX}/bin/sh-elf-as" CACHE STRING "" FORCE)
set(KOS_AFLAGS "-little" CACHE STRING "" FORCE)
set(KOS_LD "${SH_ELF_PREFIX}/bin/sh-elf-ld" CACHE STRING "" FORCE)
set(KOS_OBJCOPY "${SH_ELF_PREFIX}/bin/sh-elf-objcopy" CACHE STRING "" FORCE)
set(CMAKE_OBJCOPY ${SH_ELF_PREFIX}/bin/sh-elf-objcopy CACHE FILEPATH "")
set(CMAKE_C_COMPILER ${SH_ELF_PREFIX}/bin/sh-elf-gcc CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER ${SH_ELF_PREFIX}/bin/sh-elf-g++ CACHE FILEPATH "")
set(CMAKE_AR ${SH_ELF_PREFIX}/bin/sh-elf-ar CACHE FILEPATH "")
set(CMAKE_ASM_COMPILER ${SH_ELF_PREFIX}/bin/sh-elf-gcc CACHE FILEPATH "")
set(CMAKE_LINKER ${SH_ELF_PREFIX}/bin/sh-elf-ld CACHE FILEPATH "")
set(KOS_INC_PATHS "-I${KOS_BASE}/include -I${KOS_BASE}/kernel/arch/dreamcast/include -I${KOS_BASE}/addons/include -I${KOS_BASE}/../kos-ports/include")
set(KOS_LIB_PATHS "-L${KOS_BASE}/lib/${KOS_ARCH} -L${KOS_BASE}/addons/lib/${KOS_ARCH} -L${KOS_BASE}/../kos-ports/lib")
set(KOS_LIBS "-Wl,--start-group -lc -lgcc -Wl,--end-group")
set(KOS_CFLAGS "-D__DREAMCAST__ -ml -m4-single-only -ffunction-sections -fdata-sections -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin")
set(CMAKE_C_FLAGS "${KOS_CFLAGS} ${KOS_INC_PATHS}" CACHE STRING "C flags" FORCE)
set(CMAKE_CXX_FLAGS "${KOS_CFLAGS} ${KOS_INC_PATHS} -fno-operator-names -fno-rtti -fno-exceptions" CACHE STRING "C++ flags" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "CMAKE_C_FLAGS_RELEASE" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "CMAKE_CXX_FLAGS_RELEASE" FORCE)
set(CMAKE_C_LINK_FLAGS "${KOS_LIB_PATHS} ${KOS_LIBS} -T${KOS_BASE}/utils/ldscripts/shlelf.xc ${KOS_LIBS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_LINK_FLAGS "${KOS_LIB_PATHS} ${KOS_LIBS} -T${KOS_BASE}/utils/ldscripts/shlelf.xc ${KOS_LIBS}" CACHE STRING "" FORCE)
set_property(DIRECTORY PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
set(CMAKE_FIND_ROOT_PATH ${SH_ELF_PREFIX} $ENV{KOS_BASE}/ $ENV{KOS_BASE}/addons $ENV{KOS_BASE}/../kos-ports)
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_EXECUTABLE_SUFFIX_C ".elf" CACHE STRING "" FORCE)
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf" CACHE STRING "" FORCE)
endif ()