-
Notifications
You must be signed in to change notification settings - Fork 28
/
CMakeLists.txt
360 lines (322 loc) · 8.29 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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# ____ ___ | / _____ _____
# | __ | |___/ | |
# |___| ___| | \ __|__ | gsKit Open Source Project.
# ----------------------------------------------------------------------
# Copyright 2004 - Chris "Neovanglist" Gilbert <[email protected]>
# Licenced under Academic Free License version 2.0
# Review gsKit README & LICENSE files for further details.
cmake_minimum_required(VERSION 3.0.0)
project(gsKit)
enable_language(ASM)
if(NOT DEFINED ENV{PS2DEV})
message(FATAL_ERROR "Please kindly set $PS2DEV environment variable")
endif()
set(PS2DEV $ENV{PS2DEV})
if(NOT DEFINED ENV{GSKIT})
set(GSKIT ${PS2DEV}/gsKit)
else()
set(GSKIT $ENV{GSKIT})
endif()
set(INSTALL_LIB_DIR "${GSKIT}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${GSKIT}/include" CACHE PATH "Installation directory for headers")
set(GSKIT_EXTERNAL_LIBS "")
find_library(LIBJPEG_LIBRARY NAMES jpeg)
find_path(LIBJPEG_INCLUDE_DIR NAMES jpeglib.h)
if(LIBJPEG_LIBRARY)
list(APPEND GSKIT_EXTERNAL_LIBS ${LIBJPEG_LIBRARY})
include_directories(${LIBJPEG_INCLUDE_DIR})
add_definitions(-DHAVE_LIBJPEG)
endif()
find_library(LIBTIFF_LIBRARY NAMES tiff)
find_path(LIBTIFF_INCLUDE_DIR NAMES tiff.h)
if(LIBTIFF_LIBRARY)
list(APPEND GSKIT_EXTERNAL_LIBS lzma ${LIBTIFF_LIBRARY})
include_directories(${LIBTIFF_INCLUDE_DIR})
add_definitions(-DHAVE_LIBTIFF)
endif()
find_library(LIBZ_LIBRARY NAMES z)
find_path(LIBZ_INCLUDE_DIR NAMES zlib.h)
if(LIBZ_LIBRARY)
list(APPEND GSKIT_EXTERNAL_LIBS ${LIBZ_LIBRARY})
include_directories(${LIBZ_INCLUDE_DIR})
add_definitions(-DHAVE_ZLIB)
endif()
find_library(LIBPNG_LIBRARY NAMES png)
find_path(LIBPNG_INCLUDE_DIR NAMES png.h)
if(LIBPNG_LIBRARY)
list(APPEND GSKIT_EXTERNAL_LIBS ${LIBPNG_LIBRARY})
include_directories(${LIBPNG_INCLUDE_DIR})
add_definitions(-DHAVE_LIBPNG)
endif()
macro (add_object_library_macros objlistvar sourcefile)
set(objects_list "")
foreach(arg IN ITEMS ${ARGN})
add_library(${objlistvar}_${arg} OBJECT ${sourcefile})
target_compile_definitions(${objlistvar}_${arg} PRIVATE F_${arg}=1)
list(APPEND objects_list $<TARGET_OBJECTS:${objlistvar}_${arg}>)
endforeach()
set(${objlistvar} ${objects_list})
endmacro (add_object_library_macros)
include_directories(ee/gs/include)
add_object_library_macros(GS_CORE_OBJS ee/gs/src/gsCore.c
gsKit_vram_alloc
gsKit_vram_clear
gsKit_sync_flip
gsKit_setactive
gsKit_finish
gsKit_lock_buffer
gsKit_unlock_buffer
gsKit_lock_status
gsKit_display_buffer
gsKit_switch_context
gsKit_vsync_wait
gsKit_vsync_nowait
gsKit_get_field
gsKit_hsync_wait
gsKit_add_vsync_handler
gsKit_remove_vsync_handler
gsKit_add_hsync_handler
gsKit_remove_hsync_handler
gsKit_clear
gsKit_set_scissor
gsKit_set_test
gsKit_set_clamp
gsKit_set_primalpha
gsKit_set_texfilter
gsKit_set_dither_matrix
gsKit_set_dither
gsKit_set_drawfield
gsKit_set_finish
gsKit_queue_exec_real
gsKit_queue_reset
gsKit_queue_exec
gsKit_alloc_ucab
gsKit_free_ucab
gsKit_queue_init
gsKit_queue_free
gsKit_queue_set
gsKit_mode_switch
)
add_object_library_macros(GS_FONTM_OBJS ee/gs/src/gsFontM.c
gsKit_init_fontm
gsKit_free_fontm
gsKit_fontm_upload
gsKit_fontm_unpack
gsKit_fontm_unpack_raw
gsKit_fontm_unpack_raw_1
gsKit_fontm_print_scaled
)
add_object_library_macros(GS_HIRES_OBJS ee/gs/src/gsHires.c
gsHiresIinternals
_gsKit_create_passes
gsKit_hires_sync
gsKit_hires_flip
gsKit_hires_prepare_bg
gsKit_hires_set_bg
gsKit_hires_init_screen
gsKit_hires_init_global
gsKit_hires_deinit_global
)
add_object_library_macros(GS_INIT_OBJS ee/gs/src/gsInit.c
_gsInit_internal
gsKit_check_rom
gsKit_set_display_offset
gsKit_init_screen
gsKit_init_global_custom
gsKit_deinit_global
)
add_object_library_macros(GS_PRIMITIVE_OBJS ee/gs/src/gsPrimitive.c
gsKit_prim_point
gsKit_prim_list_points
gsKit_prim_line_3d
gsKit_prim_line_goraud_3d
gsKit_prim_list_line_goraud_3d
gsKit_prim_line_strip
gsKit_prim_line_strip_3d
gsKit_prim_sprite
gsKit_prim_triangle_3d
gsKit_prim_triangle_strip
gsKit_prim_triangle_strip_3d
gsKit_prim_triangle_fan
gsKit_prim_triangle_fan_3d
gsKit_prim_triangle_gouraud_3d
gsKit_prim_list_triangle_gouraud_3d
gsKit_prim_quad_3d
gsKit_prim_quad_gouraud_3d
)
add_object_library_macros(GS_MISC_OBJS ee/gs/src/gsMisc.c
gsKit_setup_tbw
gsKit_vram_dump
)
add_object_library_macros(GS_TEXT_MANAGER_OBJS ee/gs/src/gsTexManager.c
gsTextManagerInternals
gsKit_TexManager_init
gsKit_TexManager_setmode
gsKit_TexManager_bind
gsKit_TexManager_invalidate
gsKit_TexManager_free
gsKit_TexManager_nextFrame
)
add_object_library_macros(GS_TEXTURE_OBJS ee/gs/src/gsTexture.c
gsKit_texture_size_ee
gsKit_texture_size
gsKit_texture_to_psm16
gsKit_texture_send
gsKit_texture_send_inline
gsKit_texture_upload
gsKit_prim_sprite_texture_3d
gsKit_prim_sprite_striped_texture_3d
gsKit_prim_triangle_texture_3d
gskit_prim_list_sprite_texture_uv_3d
gsKit_prim_triangle_goraud_texture_3d
gsKit_prim_list_triangle_goraud_texture_uv_3d
gsKit_prim_list_triangle_goraud_texture_stq_3d
gsKit_prim_triangle_strip_texture
gsKit_prim_triangle_strip_texture_3d
gsKit_prim_triangle_fan_texture
gsKit_prim_triangle_fan_texture_3d
gsKit_prim_quad_texture_3d
gsKit_prim_quad_goraud_texture_3d
)
add_library(gskit STATIC
${GS_CORE_OBJS}
${GS_FONTM_OBJS}
${GS_HIRES_OBJS}
${GS_INIT_OBJS}
${GS_PRIMITIVE_OBJS}
${GS_MISC_OBJS}
${GS_TEXT_MANAGER_OBJS}
${GS_TEXTURE_OBJS}
)
target_include_directories(gskit PUBLIC ee/gs/include)
include_directories(ee/dma/include)
add_object_library_macros(DMA_CORE_OBJS ee/dma/src/dmaCore.c
dmaKit_wait
dmaKit_wait_fast
dmaKit_send
dmaKit_send_ucab
dmaKit_send_spr
dmaKit_send_chain
dmaKit_send_chain_ucab
dmaKit_send_chain_spr
dmaKit_get_spr
)
add_object_library_macros(DMA_INIT_OBJS ee/dma/src/dmaInit.c
dmaKit_init
dmaKit_chan_init
)
add_object_library_macros(DMA_SPR_OBJS ee/dma/src/dmaSpr.c
dmaKit_spr_begin
dmaKit_spr_end
dmaKit_spr_alloc
)
add_library(dmakit STATIC
${DMA_CORE_OBJS}
${DMA_INIT_OBJS}
${DMA_SPR_OBJS}
)
target_include_directories(dmakit PUBLIC ee/dma/include)
include_directories(ee/toolkit/include)
add_object_library_macros(GS_TOOLKIT_OBJS ee/toolkit/src/gsToolkit.c
gsKit_texture_finish
gsKit_texture_png
gsKit_texture_bmp
gsKit_texture_jpeg
gsKit_texture_tiff
gsKit_texture_raw
gsKit_texture_tga
gsKit_texture_fnt_raw
gsKit_init_font
gsKit_font_upload_raw
gsKit_font_upload
gsKit_font_print_scaled
)
add_library(gskit_toolkit STATIC
${GS_TOOLKIT_OBJS}
)
target_include_directories(gskit_toolkit PUBLIC ee/toolkit/include)
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
install(TARGETS gskit dmakit gskit_toolkit
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
)
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
install(DIRECTORY ee/gs/include/ ee/dma/include/ ee/toolkit/include/
DESTINATION "${INSTALL_INC_DIR}"
FILES_MATCHING PATTERN "*.h"
)
endif()
if(NOT SKIP_BUILD_EXAMPLES)
set(CMAKE_EXECUTABLE_SUFFIX .elf)
set(GSKIT_SAMPLE_LIBS "")
list(APPEND GSKIT_SAMPLE_LIBS gskit dmakit gskit_toolkit ${GSKIT_EXTERNAL_LIBS})
macro (add_executable_example targetname)
add_executable(${targetname}
examples/${targetname}/${targetname}.c
)
target_link_libraries(${targetname}
${GSKIT_SAMPLE_LIBS}
)
endmacro (add_executable_example)
set(GSKIT_SAMPLE_DIRS "")
list(APPEND GSKIT_SAMPLE_DIRS
alpha
atlas
basic
bigtex
coverflow
clut
cube
fb
fhdbg
font
fontm
modetest
modetesthires
pixelperfect
texstream
textures
vsync
)
foreach(arg IN ITEMS ${GSKIT_SAMPLE_DIRS})
add_executable_example(${arg})
endforeach()
target_link_libraries(cube
draw
math3d
)
set_property(TARGET modetest APPEND PROPERTY SOURCES examples/modetest/pad.c)
target_link_libraries(modetest
pad
)
set_property(TARGET modetesthires APPEND PROPERTY SOURCES examples/modetesthires/pad.c)
target_link_libraries(modetesthires
pad
)
add_executable(hires
examples/hires/main.c
)
target_link_libraries(hires
${GSKIT_SAMPLE_LIBS}
draw
graph
math3d
packet
dma
)
add_executable(linuz-texture
examples/linuz-texture/sample.c
examples/linuz-texture/testorig.s
examples/linuz-texture/texture.c
)
target_link_libraries(linuz-texture
${GSKIT_SAMPLE_LIBS}
)
add_executable(png-texture
examples/png-texture/textures.c
)
target_link_libraries(png-texture
${GSKIT_SAMPLE_LIBS}
)
endif()