forked from n64dev/cen64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
453 lines (382 loc) · 15.4 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
#
# CEN64: Cycle-Accurate Nintendo 64 Emulator.
# Copyright (C) 2015, Tyler J. Stachecki.
#
# This file is subject to the terms and conditions defined in
# 'LICENSE', which is part of this source code package.
#
cmake_minimum_required(VERSION 2.8)
project(cen64 C)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})
if(APPLE)
find_package(OpenGLXQuartz REQUIRED)
# Needed for signal.h on OS X.
add_definitions(-D_DARWIN_C_SOURCE)
else(APPLE)
find_package(OpenGL REQUIRED)
endif(APPLE)
find_package(Iconv REQUIRED)
find_package(OpenAL REQUIRED)
find_package(Threads REQUIRED)
# If using GCC, configure it accordingly.
if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99")
# Include architecture-specify machinery.
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE GCC_MACHINE)
string(REGEX MATCH "([a-zA-Z0-9])+" GCC_MACHINE ${GCC_MACHINE})
if (${GCC_MACHINE} MATCHES "x86.*" OR ${GCC_MACHINE} MATCHES "i.86.*")
set(CEN64_ARCH_SUPPORT "Native" CACHE STRING "Architectural extension(s) to use")
set_property(CACHE CEN64_ARCH_SUPPORT PROPERTY STRINGS Native AVX SSE4.1 SSSE3 SSE3 SSE2)
if (${CEN64_ARCH_SUPPORT} MATCHES "SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "AVX")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "Native")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
endif ()
# if (${GCC_MACHINE} MATCHES "i.86.*" OR ${GCC_MACHINE} MATCHES "x86.*")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffixed-xmm8 -ffixed-xmm9 -ffixed-xmm10")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffixed-xmm11 -ffixed-xmm12 -ffixed-xmm13 -ffixed-xmm14 -ffixed-xmm15")
# endif (${GCC_MACHINE} MATCHES "i.86.*" OR ${GCC_MACHINE} MATCHES "x86.*")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maccumulate-outgoing-args")
set(CEN64_ARCH_DIR "x86_64")
include_directories(${PROJECT_SOURCE_DIR}/os/unix/x86_64)
endif (${GCC_MACHINE} MATCHES "x86.*" OR ${GCC_MACHINE} MATCHES "i.86.*")
if (${GCC_MACHINE} STREQUAL "arm")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard -mfpu=neon")
include_directories(${PROJECT_SOURCE_DIR}/arch/arm)
include_directories(${PROJECT_SOURCE_DIR}/os/unix/arm)
endif (${GCC_MACHINE} STREQUAL "arm")
# Set architecture-independent flags.
set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -g3 -O0")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -ffast-math -DNDEBUG -s -fmerge-all-constants")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -ffast-math -DNDEBUG -ggdb3 -g3 -fmerge-all-constants")
set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG -fmerge-all-constants")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
# Enable link time optimization on recent versions.
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-s")
if (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
set(GCC_FLTO_FLAGS "-flto -fdata-sections -ffunction-sections")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${GCC_FLTO_FLAGS}")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${GCC_FLTO_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -Wl,--gc-sections")
endif (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
# Enable "unsafe" loop optimizations on recent versions.
if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funsafe-loop-optimizations")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -funsafe-loop-optimizations")
endif (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
# Check for undefined behaviour when debugging.
if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined")
endif (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
# Use fat LTO objects.
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffat-lto-objects")
endif (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
endif (${CMAKE_C_COMPILER_ID} MATCHES GNU)
# If using Clang, configure it accordingly.
if (${CMAKE_C_COMPILER_ID} MATCHES Clang)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99")
# Include architecture-specify machinery.
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE CLANG_MACHINE)
string(REGEX MATCH "([a-zA-Z0-9])+" CLANG_MACHINE ${CLANG_MACHINE})
if (${CLANG_MACHINE} MATCHES "x86.*" OR ${CLANG_MACHINE} MATCHES "i.86.*")
set(CEN64_ARCH_SUPPORT "Native" CACHE STRING "Architectural extension(s) to use")
set_property(CACHE CEN64_ARCH_SUPPORT PROPERTY STRINGS Native AVX SSE4.1 SSSE3 SSE3 SSE2)
if (${CEN64_ARCH_SUPPORT} MATCHES "SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "AVX")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "Native")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
endif ()
set(CEN64_ARCH_DIR "x86_64")
include_directories(${PROJECT_SOURCE_DIR}/os/unix/x86_64)
endif (${CLANG_MACHINE} MATCHES "x86.*" OR ${CLANG_MACHINE} MATCHES "i.86.*")
if (${CLANG_MACHINE} STREQUAL "arm")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard -mfpu=neon")
set(CEN64_ARCH_DIR "arm")
include_directories(${PROJECT_SOURCE_DIR}/os/unix/arm)
endif (${CLANG_MACHINE} STREQUAL "arm")
# Set architecture-independent flags.
if (APPLE)
set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -g3 -O0")
else ()
set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -g3 -O0 -fsanitize=undefined")
endif ()
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -DNDEBUG -ggdb3 -g3")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-s")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
endif (${CMAKE_C_COMPILER_ID} MATCHES Clang)
# If using ICC, configure it accordingly.
if (${CMAKE_C_COMPILER_ID} MATCHES Intel)
set(CMAKE_C_FLAGS "-Wall -Wno-unused-parameter -std=c99")
set(CEN64_ARCH_SUPPORT "Native" CACHE STRING "Architectural extension(s) to use")
set_property(CACHE CEN64_ARCH_SUPPORT PROPERTY STRINGS Native SSE4.1 SSSE3 SSE3 SSE2)
if (${CEN64_ARCH_SUPPORT} MATCHES "SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xSSE2")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xSSSE3")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xSSE3")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xSSE4.1")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "AVX")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xAVX")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "Native")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xHost")
endif ()
set(CEN64_ARCH_DIR "x86_64")
include_directories(${PROJECT_SOURCE_DIR}/os/unix/x86_64)
# Set architecture-independent flags.
set(CMAKE_C_FLAGS_DEBUG "-g3 -O0")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG -ipo -ffunction-sections -fdata-sections")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -ipo -ffunction-sections -fdata-sections")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -DNDEBUG -ggdb3 -g3 -ipo -ffunction-sections -fdata-sections")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
endif (${CMAKE_C_COMPILER_ID} MATCHES Intel)
# If using MSVC, configure it accordingly.
if (MSVC)
set(CEN64_ARCH_SUPPORT "SSE2" CACHE STRING "Architectural extension(s) to use")
set_property(CACHE CEN64_ARCH_SUPPORT PROPERTY STRINGS AVX SSE4.1 SSSE3 SSE3 SSE2)
if (${CEN64_ARCH_SUPPORT} MATCHES "SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE2__")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE2__ /D__SSE3__ /D__SSSE3__")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE2__ /D__SSE3__")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "SSE4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE2__ /D__SSE3__ /D__SSSE3__ /D__SSE4_1__")
elseif (${CEN64_ARCH_SUPPORT} MATCHES "AVX")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE2__ /D__SSE3__ /D__SSSE3__ /D__SSE4_1__ /arch:AVX")
endif ()
enable_language(ASM_MASM) # Are you kidding me? Really?
file(GLOB ASM_SOURCES ${PROJECT_SOURCE_DIR}/os/windows/x86_64/fpu/*.asm)
set(CEN64_ARCH_DIR "x86_64")
include_directories(${PROJECT_SOURCE_DIR}/os/windows/x86_64)
endif (MSVC)
# Print out MMIO register accesses?
option(DEBUG_MMIO_REGISTER_ACCESS "Print message on each MMIO register access?" OFF)
# Use VR4300's busy-wait-detection feature?
option(VR4300_BUSY_WAIT_DETECTION "Detect and special case VR4300 busy wait loops?" ON)
# Build RelWithDebInfo by default so builds are fast out of the box
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# Glob all the files together.
include_directories(${PROJECT_BINARY_DIR})
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/arch/${CEN64_ARCH_DIR})
include_directories(${PROJECT_SOURCE_DIR}/os/common)
include_directories(${ICONV_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${OPENGL_INCLUDE_DIR})
#
# Create lists of files.
#
set(AI_SOURCES
${PROJECT_SOURCE_DIR}/ai/context.c
${PROJECT_SOURCE_DIR}/ai/controller.c
)
set(ARCH_X86_64_SOURCES
${PROJECT_SOURCE_DIR}/arch/x86_64/tlb/tlb.c
${PROJECT_SOURCE_DIR}/arch/x86_64/rsp/vrcpsq.c
${PROJECT_SOURCE_DIR}/arch/x86_64/rsp/vmov.c
${PROJECT_SOURCE_DIR}/arch/x86_64/rsp/vdivh.c
${PROJECT_SOURCE_DIR}/arch/x86_64/rsp/rsp.c
${PROJECT_SOURCE_DIR}/arch/x86_64/rsp/vrsq.c
)
set(BUS_SOURCES
${PROJECT_SOURCE_DIR}/bus/controller.c
${PROJECT_SOURCE_DIR}/bus/memorymap.c
)
set(COMMON_SOURCES
${PROJECT_SOURCE_DIR}/common/debug.c
${PROJECT_SOURCE_DIR}/common/one_hot.c
${PROJECT_SOURCE_DIR}/common/reciprocal.c
)
set(DD_SOURCES
${PROJECT_SOURCE_DIR}/dd/controller.c
)
set(DEVICE_SOURCES
${PROJECT_SOURCE_DIR}/cen64.c
${PROJECT_SOURCE_DIR}/device/cart_db.c
${PROJECT_SOURCE_DIR}/device/device.c
${PROJECT_SOURCE_DIR}/device/netapi.c
${PROJECT_SOURCE_DIR}/device/options.c
${PROJECT_SOURCE_DIR}/device/sha1.c
)
set(OS_SOURCES
${PROJECT_SOURCE_DIR}/os/common/gl_hints.c
${PROJECT_SOURCE_DIR}/os/common/input.c
)
set(OS_POSIX_SOURCES
${PROJECT_SOURCE_DIR}/os/posix/alloc.c
${PROJECT_SOURCE_DIR}/os/posix/cpuid.c
${PROJECT_SOURCE_DIR}/os/posix/local_time.c
${PROJECT_SOURCE_DIR}/os/posix/main.c
${PROJECT_SOURCE_DIR}/os/posix/rom_file.c
${PROJECT_SOURCE_DIR}/os/posix/save_file.c
${PROJECT_SOURCE_DIR}/os/posix/timer.c
)
set(OS_WINAPI_SOURCES
${PROJECT_SOURCE_DIR}/os/winapi/alloc.c
${PROJECT_SOURCE_DIR}/os/winapi/cpuid.c
${PROJECT_SOURCE_DIR}/os/winapi/gl_config.c
${PROJECT_SOURCE_DIR}/os/winapi/gl_window.c
${PROJECT_SOURCE_DIR}/os/winapi/local_time.c
${PROJECT_SOURCE_DIR}/os/winapi/main.c
${PROJECT_SOURCE_DIR}/os/winapi/rom_file.c
${PROJECT_SOURCE_DIR}/os/winapi/save_file.c
${PROJECT_SOURCE_DIR}/os/winapi/timer.c
)
set(OS_X11_SOURCES
${PROJECT_SOURCE_DIR}/os/x11/gl_config.c
${PROJECT_SOURCE_DIR}/os/x11/gl_window.c
)
set(PI_SOURCES
${PROJECT_SOURCE_DIR}/pi/controller.c
${PROJECT_SOURCE_DIR}/pi/is_viewer.c
)
set(RDP_SOURCES
${PROJECT_SOURCE_DIR}/rdp/cpu.c
${PROJECT_SOURCE_DIR}/rdp/interface.c
${PROJECT_SOURCE_DIR}/rdp/n64video.c
)
set(RI_SOURCES
${PROJECT_SOURCE_DIR}/ri/controller.c
)
set(RSP_SOURCES
${PROJECT_SOURCE_DIR}/rsp/cp0.c
${PROJECT_SOURCE_DIR}/rsp/cp2.c
${PROJECT_SOURCE_DIR}/rsp/cpu.c
${PROJECT_SOURCE_DIR}/rsp/decoder.c
${PROJECT_SOURCE_DIR}/rsp/functions.c
${PROJECT_SOURCE_DIR}/rsp/interface.c
${PROJECT_SOURCE_DIR}/rsp/opcodes.c
${PROJECT_SOURCE_DIR}/rsp/pipeline.c
${PROJECT_SOURCE_DIR}/rsp/vfunctions.c
)
set(SI_SOURCES
${PROJECT_SOURCE_DIR}/si/cic.c
${PROJECT_SOURCE_DIR}/si/controller.c
${PROJECT_SOURCE_DIR}/si/pak.c
${PROJECT_SOURCE_DIR}/si/pak_transfer.c
${PROJECT_SOURCE_DIR}/si/gb.c
${PROJECT_SOURCE_DIR}/si/rtc.c
)
set(VI_SOURCES
${PROJECT_SOURCE_DIR}/vi/controller.c
${PROJECT_SOURCE_DIR}/vi/render.c
${PROJECT_SOURCE_DIR}/vi/window.c
)
set(VR4300_SOURCES
${PROJECT_SOURCE_DIR}/vr4300/cp0.c
${PROJECT_SOURCE_DIR}/vr4300/cp1.c
${PROJECT_SOURCE_DIR}/vr4300/cpu.c
${PROJECT_SOURCE_DIR}/vr4300/dcache.c
${PROJECT_SOURCE_DIR}/vr4300/decoder.c
${PROJECT_SOURCE_DIR}/vr4300/fault.c
${PROJECT_SOURCE_DIR}/vr4300/functions.c
${PROJECT_SOURCE_DIR}/vr4300/icache.c
${PROJECT_SOURCE_DIR}/vr4300/interface.c
${PROJECT_SOURCE_DIR}/vr4300/opcodes.c
${PROJECT_SOURCE_DIR}/vr4300/pipeline.c
${PROJECT_SOURCE_DIR}/vr4300/segment.c
)
#
# Build OS_SOURCES list.
#
if (DEFINED WIN32)
include_directories(${PROJECT_SOURCE_DIR}/os/winapi)
set(EXTRA_OS_EXE WIN32)
if (NOT MSVC)
set(EXTRA_OS_LIBS mingw32 opengl32 winmm ws2_32)
else ()
set(EXTRA_OS_LIBS opengl32 winmm ws2_32)
endif ()
list(APPEND OS_SOURCES
${OS_COMMON_SOURCES}
${OS_WINAPI_SOURCES}
)
else ()
include_directories(${PROJECT_SOURCE_DIR}/os/posix)
include_directories(${PROJECT_SOURCE_DIR}/os/x11)
include_directories(${X11_xf86vmode_INCLUDE_PATH})
list(APPEND OS_SOURCES
${OS_COMMON_SOURCES}
${OS_POSIX_SOURCES}
${OS_X11_SOURCES}
)
endif (DEFINED WIN32)
#
# Glob all the files together.
#
if (DEFINED UNIX)
find_package(X11 REQUIRED)
if (${CMAKE_C_COMPILER_ID} MATCHES GNU OR ${CMAKE_C_COMPILER_ID} MATCHES Clang OR ${CMAKE_C_COMPILER_ID} MATCHES Intel)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE")
endif (${CMAKE_C_COMPILER_ID} MATCHES GNU OR ${CMAKE_C_COMPILER_ID} MATCHES Clang OR ${CMAKE_C_COMPILER_ID} MATCHES Intel)
endif (DEFINED UNIX)
#
# Configure the common header.
#
configure_file(
"${PROJECT_SOURCE_DIR}/common.h.in"
"${PROJECT_BINARY_DIR}/common.h"
)
#
# Create the executable.
#
if (NOT MSVC)
set_source_files_properties(${PROJECT_SOURCE_DIR}/rdp/n64video.c PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
endif (NOT MSVC)
add_executable(cen64
${EXTRA_OS_EXE}
${ASM_SOURCES}
${AI_SOURCES}
${ARCH_X86_64_SOURCES}
${BUS_SOURCES}
${COMMON_SOURCES}
${DD_SOURCES}
${DEVICE_SOURCES}
${OS_SOURCES}
${PI_SOURCES}
${RDP_SOURCES}
${RI_SOURCES}
${RSP_SOURCES}
${SI_SOURCES}
${VI_SOURCES}
${VR4300_SOURCES}
)
target_link_libraries(cen64
${EXTRA_OS_LIBS}
${OPENAL_LIBRARY}
${OPENGL_gl_LIBRARY}
${ICONV_LIBRARIES}
${X11_X11_LIB}
${CMAKE_THREAD_LIBS_INIT}
)