aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/cmake/flags.cmake
blob: fdc479e87c968690570981bfe314cbee40729420 (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
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
# PSn00bSDK interface targets
# (C) 2021-2022 spicyjpeg - MPL licensed

# This script creates several "virtual" targets (psn00bsdk_*) that set include
# directories and compiler flags when a target is linked against them. It is
# only used when building libpsn00b, as CMake automatically saves these targets
# into the export script once libpsn00b is installed.

add_library   (psn00bsdk INTERFACE)
link_libraries(psn00bsdk)

target_compile_options(
	psn00bsdk INTERFACE
		# Options common to all target types
		-g
		-Wa,--strip-local-absolute
		-ffreestanding
		-fno-builtin
		-nostdlib
		-fdata-sections
		-ffunction-sections
		-fsigned-char
		-fno-strict-overflow
		-fdiagnostics-color=always
		-msoft-float
		-march=r3000
		-mtune=r3000
		-mabi=32
		-mno-mt
		-mno-llsc
	$<$<COMPILE_LANGUAGE:CXX>:
		# Options common to all target types (C++)
		-fno-exceptions
		-fno-rtti
		-fno-unwind-tables
		-fno-threadsafe-statics
		-fno-use-cxa-atexit
	>
	$<IF:$<CONFIG:Debug>,
		# Options for debug builds
		-Og
		-mdivide-breaks
	,
		# Options for release builds
		-O2
	>
	$<$<STREQUAL:$<UPPER_CASE:$<TARGET_PROPERTY:PSN00BSDK_TARGET_TYPE>>,EXECUTABLE_GPREL>:
		# Options for executables with $gp-relative addressing
		-G8
		-fno-pic
		-mno-abicalls
		-mgpopt
		-mno-extern-sdata
	>
	$<$<STREQUAL:$<UPPER_CASE:$<TARGET_PROPERTY:PSN00BSDK_TARGET_TYPE>>,EXECUTABLE_NOGPREL>:
		# Options for executables without $gp-relative addressing
		-G0
		-fno-pic
		-mno-abicalls
		-mno-gpopt
	>
	$<$<STREQUAL:$<UPPER_CASE:$<TARGET_PROPERTY:PSN00BSDK_TARGET_TYPE>>,SHARED_LIBRARY>:
		# Options for DLLs
		-G0
		-fPIC
		-mabicalls
		-mno-gpopt
		-mshared
	>
)
target_link_options(
	psn00bsdk INTERFACE
		# Options common to all target types
		-nostdlib
		-Wl,-gc-sections
	$<$<STREQUAL:$<UPPER_CASE:$<TARGET_PROPERTY:PSN00BSDK_TARGET_TYPE>>,EXECUTABLE_GPREL>:
		# Options for executables with $gp-relative addressing
		-G8
		-static
	>
	$<$<STREQUAL:$<UPPER_CASE:$<TARGET_PROPERTY:PSN00BSDK_TARGET_TYPE>>,EXECUTABLE_NOGPREL>:
		# Options for executables without $gp-relative addressing
		-G0
		-static
	>
	$<$<STREQUAL:$<UPPER_CASE:$<TARGET_PROPERTY:PSN00BSDK_TARGET_TYPE>>,SHARED_LIBRARY>:
		# Options for DLLs
		-G0
		-shared
	>
)
target_compile_definitions(
	psn00bsdk INTERFACE
		PSN00BSDK=1
	$<IF:$<CONFIG:Debug>,
		#NDEBUG=0
	,
		NDEBUG=1
	>
)