-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
258 lines (241 loc) · 8.14 KB
/
Copy pathCMakeLists.txt
File metadata and controls
258 lines (241 loc) · 8.14 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
cmake_minimum_required(VERSION 3.10)
# Load the PSP platform configuration BEFORE project()
set(CMAKE_SYSTEM_CMAKE_PLATFORM_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(${CMAKE_SYSTEM_CMAKE_PLATFORM_PATH}/PSP.cmake)
project(OSLib C CXX ASM)
# Always export a compilation database; run-cppcheck.sh analyses through it.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set C and C++ standards
set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Set the output library
set(TARGET_LIB osl)
add_library(${TARGET_LIB} STATIC)
# Specify the output directory for the .a file (project root directory)
set_target_properties(${TARGET_LIB} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
# Include directories
include_directories(
INTERFACE PUBLIC_HEADER $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/libintraFont/include>
INTERFACE PUBLIC_HEADER $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/libpspmath/include>
INTERFACE PRIVATE_HEADER $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/giflib>
${PROJECT_BINARY_DIR} # For generated osl_config.h
src
src/adhoc
)
# Treat third-party library directories as system includes to suppress warnings
include_directories(SYSTEM
${PROJECT_SOURCE_DIR}/lib/giflib
${PROJECT_SOURCE_DIR}/lib/libintraFont/include
${PROJECT_SOURCE_DIR}/lib/libpspmath/include
)
# Define the source files
set(SOURCE_DIR src)
set(SFONT_SOURCES
${SOURCE_DIR}/sfont.c
)
set(PSPMATH_SOURCES
lib/libpspmath/src/printMatrixFloat.c
lib/libpspmath/src/vfpu_srand.c
lib/libpspmath/src/vfpu_randf.c
lib/libpspmath/src/vfpu_rand_8888.c
lib/libpspmath/src/vfpu_identity_matrix.c
lib/libpspmath/src/vfpu_translate_matrix.c
lib/libpspmath/src/vfpu_perspective_matrix.c
lib/libpspmath/src/vfpu_ortho_matrix.c
lib/libpspmath/src/vfpu_sinf.c
lib/libpspmath/src/vfpu_cosf.c
lib/libpspmath/src/vfpu_tanf.c
lib/libpspmath/src/vfpu_asinf.c
lib/libpspmath/src/vfpu_acosf.c
lib/libpspmath/src/vfpu_atanf.c
lib/libpspmath/src/vfpu_sinhf.c
lib/libpspmath/src/vfpu_coshf.c
lib/libpspmath/src/vfpu_tanhf.c
lib/libpspmath/src/vfpu_sincos.c
lib/libpspmath/src/vfpu_expf.c
lib/libpspmath/src/vfpu_logf.c
lib/libpspmath/src/vfpu_fabsf.c
lib/libpspmath/src/vfpu_sqrtf.c
lib/libpspmath/src/vfpu_powf.c
lib/libpspmath/src/vfpu_fmodf.c
lib/libpspmath/src/vfpu_fminf.c
lib/libpspmath/src/vfpu_fmaxf.c
lib/libpspmath/src/vfpu_ease_in_out.c
lib/libpspmath/src/vfpu_normalize_vector.c
lib/libpspmath/src/vfpu_zero_vector.c
lib/libpspmath/src/vfpu_scale_vector.c
lib/libpspmath/src/vfpu_add_vector.c
lib/libpspmath/src/vfpu_envmap_matrix.c
lib/libpspmath/src/vfpu_sphere_to_cartesian.c
lib/libpspmath/src/vfpu_quaternion_identity.c
lib/libpspmath/src/vfpu_quaternion_copy.c
lib/libpspmath/src/vfpu_quaternion_multiply.c
lib/libpspmath/src/vfpu_quaternion_normalize.c
lib/libpspmath/src/vfpu_quaternion_exp.c
lib/libpspmath/src/vfpu_quaternion_ln.c
lib/libpspmath/src/vfpu_quaternion_sample_linear.c
lib/libpspmath/src/vfpu_quaternion_from_euler.c
lib/libpspmath/src/vfpu_quaternion_to_matrix.c
lib/libpspmath/src/vfpu_quaternion_sample_hermite.c
lib/libpspmath/src/vfpu_quaternion_hermite_tangent.c
)
set(GIFLIB_SOURCES
lib/giflib/gif2rgb.c
lib/giflib/dgif_lib.c
lib/giflib/egif_lib.c
lib/giflib/gif_err.c
lib/giflib/gifalloc.c
lib/giflib/quantize.c
lib/giflib/openbsd-reallocarray.c
)
set(INTRAFONT_SOURCES
lib/libintraFont/src/intraFont.c
lib/libintraFont/src/libccc.c
)
set(LIB_SOURCES
${SOURCE_DIR}/adhoc/pspadhoc.c
${SOURCE_DIR}/audio/audio.c
${SOURCE_DIR}/audio/bgm.c
${SOURCE_DIR}/audio/media.c
${SOURCE_DIR}/audio/mod.c
${SOURCE_DIR}/browser.c
${SOURCE_DIR}/dialog.c
${SOURCE_DIR}/drawing.c
${SOURCE_DIR}/image.c
${SOURCE_DIR}/image/oslConvertImageTo.c
${SOURCE_DIR}/image/oslDrawImage.c
${SOURCE_DIR}/image/oslDrawImageBig.c
${SOURCE_DIR}/image/oslDrawImageSimple.c
${SOURCE_DIR}/image/oslGetImagePixel.c
${SOURCE_DIR}/image/oslLockImage.c
${SOURCE_DIR}/image/oslMoveImageTo.c
${SOURCE_DIR}/image/oslResetImageProperties.c
${SOURCE_DIR}/image/oslScaleImage.c
${SOURCE_DIR}/image/oslSetDrawBuffer.c
${SOURCE_DIR}/image/oslSetImagePixel.c
${SOURCE_DIR}/image/oslSwizzleImage.c
${SOURCE_DIR}/image/oslUnswizzleImage.c
${SOURCE_DIR}/keys.c
${SOURCE_DIR}/map.c
${SOURCE_DIR}/mem/oslGetRamStatus.c
${SOURCE_DIR}/messagebox.c
${SOURCE_DIR}/net.c
${SOURCE_DIR}/osk.c
${SOURCE_DIR}/oslHandleLoadNoFailError.c
${SOURCE_DIR}/oslib.c
${SOURCE_DIR}/palette.c
${SOURCE_DIR}/saveload.c
${SOURCE_DIR}/shape.c
${SOURCE_DIR}/image/oslLoadImageFile.c
${SOURCE_DIR}/image/oslWriteImageFile.c
${SOURCE_DIR}/splash/oslShowSplashScreen1.c
${SOURCE_DIR}/splash/oslShowSplashScreen2.c
${SOURCE_DIR}/stub.S
${SOURCE_DIR}/text.c
${SOURCE_DIR}/usb.c
${SOURCE_DIR}/vfile/vfsFile.c
${SOURCE_DIR}/vfile/VirtualFile.c
${SOURCE_DIR}/vfpu.c
${SOURCE_DIR}/vram_mgr.c
)
include(${CMAKE_SYSTEM_CMAKE_PLATFORM_PATH}/IMG.cmake)
# Specify that stub.S is an assembly file
set_source_files_properties(${SOURCE_DIR}/stub.S PROPERTIES LANGUAGE ASM)
# Suppress warnings for third-party library sources
set_source_files_properties(
${PSPMATH_SOURCES}
${GIFLIB_SOURCES}
${INTRAFONT_SOURCES}
PROPERTIES
COMPILE_FLAGS "-w"
)
# Add sources to the target
target_sources(${TARGET_LIB} PRIVATE
${SFONT_SOURCES}
${PSPMATH_SOURCES}
${GIFLIB_SOURCES}
${INTRAFONT_SOURCES}
${LIB_SOURCES}
)
# Installation instructions
install(TARGETS ${TARGET_LIB} DESTINATION ${PSPDIR}/lib)
# Include directories installation (headers)
install(FILES
lib/libintraFont/include/intraFont.h
lib/libintraFont/include/libccc.h
DESTINATION ${PSPDIR}/include/oslib
)
install(FILES
lib/libpspmath/include/pspmath.h
DESTINATION ${PSPDIR}/include/oslib
)
install(FILES
${SOURCE_DIR}/adhoc/pspadhoc.h
DESTINATION ${PSPDIR}/include/oslib/adhoc
)
install(FILES
${SOURCE_DIR}/oslmath.h
${SOURCE_DIR}/net.h
${SOURCE_DIR}/browser.h
${SOURCE_DIR}/audio.h
${SOURCE_DIR}/bgm.h
${SOURCE_DIR}/dialog.h
${SOURCE_DIR}/drawing.h
${SOURCE_DIR}/keys.h
${SOURCE_DIR}/map.h
${SOURCE_DIR}/messagebox.h
${SOURCE_DIR}/osk.h
${SOURCE_DIR}/saveload.h
${SOURCE_DIR}/oslib.h
${SOURCE_DIR}/text.h
${SOURCE_DIR}/usb.h
${SOURCE_DIR}/vfpu_ops.h
${SOURCE_DIR}/VirtualFile.h
${SOURCE_DIR}/vram_mgr.h
${SOURCE_DIR}/ccc.h
${SOURCE_DIR}/sfont.h
${PROJECT_BINARY_DIR}/osl_config.h
DESTINATION ${PSPDIR}/include/oslib
)
# Add Cppcheck execution
find_program(CPPCHECK cppcheck)
if(CPPCHECK)
add_custom_target(
cppcheck
COMMAND ${CMAKE_SOURCE_DIR}/run-cppcheck.sh --cppcheck ${CPPCHECK} --build-dir ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running Cppcheck over the project (fails the build on any finding)..."
)
add_custom_target(
cppcheck-report
COMMAND ${CMAKE_SOURCE_DIR}/run-cppcheck.sh --cppcheck ${CPPCHECK} --build-dir ${CMAKE_BINARY_DIR} --report ${CMAKE_SOURCE_DIR}/cppcheck-report.txt
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running Cppcheck and writing the findings to cppcheck-report.txt..."
)
else()
message(WARNING "Cppcheck not found, skipping static analysis.")
endif()
# Add Uncrustify execution
find_program(UNCRUSTIFY uncrustify)
if(UNCRUSTIFY)
add_custom_target(
uncrustify
COMMAND ${CMAKE_SOURCE_DIR}/run-uncrustify.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running Uncrustify to format the code (respecting .uncrustifyignore)..."
)
add_custom_target(
uncrustify-check
COMMAND ${CMAKE_SOURCE_DIR}/run-uncrustify.sh --check
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Checking code formatting with Uncrustify (no files are modified)..."
)
else()
message(WARNING "Uncrustify not found, skipping code formatting.")
endif()