-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
620 lines (531 loc) · 16.9 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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
SET(TargetName "USBqemu-wheel")
if (NOT TOP_CMAKE_WAS_SOURCED)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
MACRO(getenv_path VAR)
SET(ENV_${VAR} $ENV{${VAR}})
# replace won't work if var is blank
IF (ENV_${VAR})
STRING( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
ENDIF ()
ENDMACRO(getenv_path)
PROJECT(${TargetName})
INCLUDE(FindPkgConfig)
endif()
set(CMAKE_MODULE_PATH
"${${TargetName}_SOURCE_DIR}/cmake"
)
SET (PLUGIN_VERSION_MAJOR "0")
SET (PLUGIN_VERSION_MINOR "10")
SET (PLUGIN_VERSION_PATCH "1")
SET (PLUGIN_VERSION "${PLUGIN_VERSION_MAJOR}.${PLUGIN_VERSION_MINOR}.${PLUGIN_VERSION_PATCH}")
IF(WIN32)
SET (TargetNameVer "${TargetName}-${PLUGIN_VERSION}-${CMAKE_GENERATOR_PLATFORM}")
ELSE()
SET (TargetNameVer "${TargetName}-${PLUGIN_VERSION}")
ENDIF()
SET (DEBIAN_PACKAGE "libusbqemu-wheel-unstable")
# Breaks win32 resources' defines
OPTION (PLUGIN_ENABLE_UNITY_BUILD "Enable unity build. Concatenate source files into one unit." FALSE)
OPTION (PLUGIN_BUILD_64BIT "Enable 64bit build." FALSE)
IF(WIN32)
OPTION (PLUGIN_BUILD_RAW "Build with raw input api" TRUE)
OPTION (PLUGIN_BUILD_DX "Build with DX input" TRUE)
OPTION (PLUGIN_BUILD_WITH_DXSDK "Build with DX 2010 SDK" FALSE)
OPTION (PLUGIN_FIND_WINSDK "Find Windows SDK if your build tools don't include it automatically" FALSE)
ELSE(WIN32)
OPTION (PLUGIN_BUILD_PULSE "Build with PulseAudio" TRUE)
OPTION (PLUGIN_BUILD_DYNLINK_PULSE "Load PulseAudio dynamically" TRUE)
ENDIF(WIN32)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-D_DEBUG=1)
ENDIF()
IF(_DEBUG)
ADD_DEFINITIONS(-D_DEBUG=1)
ELSE(_DEBUG)
MESSAGE("Define _DEBUG for debug print.")
ENDIF(_DEBUG)
#ADD_DEFINITIONS(-DUSING_X11=1)
# 64 bits specific configuration
IF(NOT PLUGIN_BUILD_64BIT AND CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT WIN32)
MESSAGE("Building as x86 on x86_64.")
# Do not search library in /usr/lib64
SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF)
SET_PROPERTY(GLOBAL PROPERTY COMPILE_DEFINITIONS "-m32")
# Force the search on 32-bits path.
IF(EXISTS "/usr/lib32")
SET(CMAKE_LIBRARY_ARCHITECTURE "../lib32")
ENDIF()
ENDIF()
#IF(EXISTS "/usr/lib/i386-linux-gnu")
# SET(CMAKE_LIBRARY_ARCHITECTURE "i686-linux-gnu")
#ENDIF()
# Ripped from cheind.wordpress.com
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
set(files ${${SOURCE_VARIABLE_NAME}})
set(FILEEXT c)
foreach(source_file ${files} )
STRING(REGEX MATCH "\\.[cC][pP][pP]$" match "${source_file}")
IF(match)
set(FILEEXT "cpp")
ENDIF()
endforeach(source_file)
# Generate a unique filename for the unity build translation unit
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.${FILEEXT})
# Exclude all translation units from compilation
set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)
# Open the ub file
FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
# Add include statement for each translation unit
foreach(source_file ${files} )
FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n")
endforeach(source_file)
# Complement list of translation units with the name of ub
set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
endfunction(enable_unity_build)
# Generate version.h
SET(hdr_file ${CMAKE_CURRENT_BINARY_DIR}/generated/version.h)
FILE(WRITE ${hdr_file} "// Generated by CMake\n")
FILE( APPEND ${hdr_file} "#ifndef VERSION_H\n")
FILE( APPEND ${hdr_file} "#define VERSION_H\n")
FILE( APPEND ${hdr_file} "#define VER_REV ${PLUGIN_VERSION_MAJOR}\n")
FILE( APPEND ${hdr_file} "#define VER_BLD ${PLUGIN_VERSION_MINOR}\n")
FILE( APPEND ${hdr_file} "#define VER_FIX ${PLUGIN_VERSION_PATCH}\n")
FILE( APPEND ${hdr_file} "#endif\n")
SET(hdr_file ${CMAKE_CURRENT_BINARY_DIR}/generated/gmem-size.h)
FILE(WRITE ${hdr_file} "// Generated by CMake\n")
FILE( APPEND ${hdr_file} "#pragma once\n")
IF (PLUGIN_BUILD_64BIT)
FILE( APPEND ${hdr_file} "#define G_MAXSIZE G_MAXUINT64")
ELSE()
FILE( APPEND ${hdr_file} "#define G_MAXSIZE G_MAXUINT32")
ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/generated)
#
# Source files
#
SET(HDRS_SAMPLERATE
./src/3rdparty/libsamplerate/common.h
./src/3rdparty/libsamplerate/config.h
./src/3rdparty/libsamplerate/fastest_coeffs.h
./src/3rdparty/libsamplerate/float_cast.h
./src/3rdparty/libsamplerate/high_qual_coeffs.h
./src/3rdparty/libsamplerate/mid_qual_coeffs.h
./src/3rdparty/libsamplerate/samplerate.h
)
SET(SRCS_SAMPLERATE
./src/3rdparty/libsamplerate/samplerate.c
./src/3rdparty/libsamplerate/src_linear.c
./src/3rdparty/libsamplerate/src_sinc.c
./src/3rdparty/libsamplerate/src_zoh.c
)
SET(HDRS_PLG
./src/USB.h
./src/PS2Etypes.h
./src/PS2Edefs.h
./src/proxybase.h
./src/deviceproxy.h
./src/configuration.h
./src/platcompat.h
./src/osdebugout.h
./src/helpers.h
./src/readerwriterqueue/readerwriterqueue.h
./src/readerwriterqueue/atomicops.h
)
SET(SRCS_PLG
./src/USB.cpp
./src/deviceproxy.cpp
./src/configuration.cpp
./src/osdebugout.cpp
./src/device_init.cpp
)
SET(HDRS_QEMU
./src/qemu-usb/glib.h
./src/qemu-usb/vl.h
./src/qemu-usb/qusb.h
./src/qemu-usb/USBinternal.h
./src/qemu-usb/desc.h
./src/qemu-usb/iov.h
./src/qemu-usb/queue.h
./src/qemu-usb/hid.h
./src/qemu-usb/input-keymap.h
)
SET(SRCS_QEMU
#./src/qemu-usb/usb-hub.cpp
./src/qemu-usb/glib.cpp
./src/qemu-usb/vl.cpp
./src/qemu-usb/iov.cpp
./src/qemu-usb/desc.cpp
./src/qemu-usb/core.cpp
./src/qemu-usb/bus.cpp
./src/qemu-usb/usb-ohci.cpp
./src/qemu-usb/hid.cpp
./src/qemu-usb/input-keymap-qcode-to-qnum.cpp
)
SET(HDRS_MSD
./src/usb-msd/usb-msd.h
)
SET(SRCS_MSD
./src/usb-msd/usb-msd.cpp
)
SET(HDRS_PAD
./src/usb-pad/usb-pad.h
./src/usb-pad/padproxy.h
./src/usb-pad/lg/lg_ff.h
)
SET(SRCS_PAD
# ./src/usb-pad/bitjuggling.cpp
./src/usb-pad/usb-pad.cpp
./src/usb-pad/usb-pad-ff.cpp
./src/usb-pad/lg/lg_ff.cpp
./src/usb-pad/usb-seamic.cpp
)
SET(HDRS_MIC
./src/usb-mic/audio.h
./src/usb-mic/audiodev.h
./src/usb-mic/audiodeviceproxy.h
./src/usb-mic/usb-mic-singstar.h
./src/usb-mic/usb-headset.h
./src/usb-mic/audiodev-noop.h
)
SET(SRCS_MIC
./src/usb-mic/usb-mic-singstar.cpp
./src/usb-mic/usb-mic-logitech.cpp
./src/usb-mic/usb-headset.cpp
)
SET(SRCS_EYETOY
./src/3rdparty/jpgd/jpgd.cpp
./src/3rdparty/jo_mpeg/jo_mpeg.c
./src/usb-eyetoy/usb-eyetoy-webcam.cpp
)
SET(HDRS_EYETOY
./src/3rdparty/jpgd/jpgd.h
./src/3rdparty/jo_mpeg/jo_mpeg.h
./src/usb-eyetoy/videodeviceproxy.h
./src/usb-eyetoy/videodev.h
./src/usb-eyetoy/usb-eyetoy-webcam.h
./src/usb-eyetoy/ov519.h
)
SET(HDRS_HID
./src/usb-hid/hidproxy.h
./src/usb-hid/usb-hid.h
./src/usb-hid/noop.h
)
SET(SRCS_HID
./src/usb-hid/usb-hid.cpp
)
# shared/global functions
SET(HDRS_SHARED
./src/shared/shared.h
./src/shared/inifile.h
./src/shared/ringbuffer.h
)
SET(SRCS_SHARED
./src/shared/shared.cpp
./src/shared/inifile.cpp
./src/shared/ringbuffer.cpp
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty)
ADD_DEFINITIONS(-DLIBSRC_ONLY_FAST -DHAVE_LRINT=1 -DHAVE_LRINTF=1)
ADD_DEFINITIONS(-DHAVE_LIBM=1 -DHAVE_INTTYPES_H=1 -DHAVE_DLFCN_H=1)
ADD_DEFINITIONS(-DGCC_MAJOR_VERSION=6)
#
# WIN32 specific source files
#
IF(WIN32)
ADD_DEFINITIONS(-DUNICODE)
ADD_DEFINITIONS(-D_UNICODE)
FILE(GLOB SRCS_API_INITS ./src/*/api_init_win32.cpp)
LIST(APPEND HDRS_WIN32
./src/Win32/resource.h
./src/Win32/Config.h
)
LIST(APPEND SRCS_WIN32
./src/Win32/Config.cpp
)
IF(MINGW)
LIST(APPEND SRCS_WIN32
./src/Win32/guid.cpp
)
ENDIF(MINGW)
LIST(APPEND HDRS_MIC
./src/usb-mic/audiodev-wasapi.h
)
LIST(APPEND SRCS_MIC
./src/usb-mic/audiodev-wasapi.cpp
)
LIST(APPEND SRCS_MSD
./src/usb-msd/usb-msd-win32.cpp
)
LIST(APPEND HDRS_SHARED
./src/shared/hidapi.h
./src/shared/rawinput.h
)
LIST(APPEND SRCS_SHARED
./src/shared/hidapi.cpp
./src/shared/rawinput.cpp
)
LIST(APPEND HDRS_QEMU
./src/qemu-usb/input-keymap-win32-to-qcode.h
)
LIST(APPEND SRCS_QEMU
./src/qemu-usb/input-keymap-win32-to-qcode.cpp
)
LIST(APPEND HDRS_HID
./src/usb-hid/raw/rawinput.h
)
LIST(APPEND SRCS_HID
# ./src/usb-hid/win32/mouse.cpp
./src/usb-hid/raw/rawinput.cpp
)
LIST(APPEND HDRS_EYETOY
./src/usb-eyetoy/cam-windows.h
)
LIST(APPEND SRCS_EYETOY
./src/usb-eyetoy/cam-windows.cpp
)
LIST(APPEND HDRS ${HDRS_WIN32})
LIST(APPEND SRCS ${SRCS_WIN32})
IF(PLUGIN_BUILD_DX)
ADD_DEFINITIONS(-DBUILD_DX=1)
IF(PLUGIN_BUILD_WITH_DXSDK)
getenv_path(DXSDK_DIR)
SET (BUILD_DX_INCLUDE "${ENV_DXSDK_DIR}/Include" CACHE PATH "DirectX include dir")
SET (BUILD_DX_LIB "${ENV_DXSDK_DIR}/Lib/x86" CACHE PATH "DirectX library dir")
ELSE(PLUGIN_BUILD_WITH_DXSDK)
IF(PLUGIN_FIND_WINSDK)
include(FindWindowsSDK)
get_windowssdk_include_dirs(${WINDOWSSDK_PREFERRED_DIR} BUILD_DX_INCLUDE)
get_windowssdk_library_dirs(${WINDOWSSDK_PREFERRED_DIR} BUILD_DX_LIB)
ENDIF(PLUGIN_FIND_WINSDK)
ENDIF(PLUGIN_BUILD_WITH_DXSDK)
INCLUDE_DIRECTORIES(${BUILD_DX_INCLUDE})
LINK_DIRECTORIES(${BUILD_DX_LIB})
LIST(APPEND HDRS_DX
./src/usb-pad/dx/dx.h
./src/usb-pad/dx/versionproxy.h
./src/usb-pad/dx/usb-pad-dx.h
)
LIST(APPEND SRCS_DX
./src/usb-pad/dx/dinput.cpp
./src/usb-pad/dx/dinput-config.cpp
./src/usb-pad/dx/usb-pad-dx.cpp
)
SOURCE_GROUP("Header Files\\usb-pad\\Dx" FILES ${HDRS_DX})
SOURCE_GROUP("Source Files\\usb-pad\\Dx" FILES ${SRCS_DX})
LIST(APPEND HDRS_PAD ${HDRS_DX})
LIST(APPEND SRCS_PAD ${SRCS_DX})
LIST(APPEND LIBS dxguid dinput8 comctl32)
FILE(GLOB DX_RCS ./src/usb-pad/dx/*.rc)
ENDIF(PLUGIN_BUILD_DX)
IF(PLUGIN_BUILD_RAW)
ADD_DEFINITIONS(-DBUILD_RAW=1)
LIST(APPEND HDRS_RAW
./src/usb-pad/raw/usb-pad-raw.h
./src/usb-pad/raw/raw-config-res.h
)
LIST(APPEND SRCS_RAW
./src/usb-pad/raw/usb-pad-raw.cpp
./src/usb-pad/raw/raw-config.cpp
)
SOURCE_GROUP("Header Files\\usb-pad\\Raw" FILES ${HDRS_RAW})
SOURCE_GROUP("Source Files\\usb-pad\\Raw" FILES ${SRCS_RAW})
LIST(APPEND HDRS_PAD ${HDRS_RAW})
LIST(APPEND SRCS_PAD ${SRCS_RAW})
LIST(APPEND LIBS setupapi)
FILE(GLOB RAW_RCS ./src/usb-pad/raw/*.rc)
ENDIF(PLUGIN_BUILD_RAW)
FILE(GLOB RCS ./src/Win32/*.rc)
FILE(GLOB DEF ./src/Win32/*.def)
IF(MSVC)
MESSAGE("Adding parallel build flag to CMAKE_CXX_FLAGS")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX")
ENDIF()
ENDIF(WIN32)
#
# Linux specific source files
#
IF(UNIX)
FILE(GLOB SRCS_API_INITS ./src/*/api_init_linux.cpp)
LIST(APPEND HDRS_LINUX
./src/linux/ini.h
./src/linux/actualfile.h
./src/linux/config.h
./src/linux/util.h
)
LIST(APPEND SRCS_PLG
./src/icon_buzz_24.cpp
)
LIST(APPEND HDRS
${HDRS_LINUX}
./src/gtk.h
./src/icon_buzz_24.h
)
LIST(APPEND SRCS_MSD
./src/usb-msd/usb-msd-gtk.cpp
)
LIST(APPEND HDRS_PAD
./src/usb-pad/joydev/joydev.h
./src/usb-pad/evdev/shared.h
./src/usb-pad/evdev/evdev.h
./src/usb-pad/evdev/evdev-ff.h
)
LIST(APPEND SRCS_PAD
./src/usb-pad/joydev/joydev.cpp
./src/usb-pad/joydev/joydev-gtk.cpp
./src/usb-pad/evdev/shared-gtk.cpp
./src/usb-pad/evdev/evdev-ff.cpp
./src/usb-pad/evdev/evdev.cpp
./src/usb-pad/evdev/evdev-gtk.cpp
)
LIST(APPEND HDRS_HID
./src/usb-hid/evdev/evdev.h
)
LIST(APPEND SRCS_HID
./src/usb-hid/evdev/evdev.cpp
./src/usb-hid/evdev/evdev-gtk.cpp
)
LIST(APPEND HDRS_EYETOY
./src/usb-eyetoy/cam-linux.h
)
LIST(APPEND SRCS_EYETOY
./src/usb-eyetoy/cam-linux.cpp
)
LIST(APPEND SRCS_LINUX
./src/linux/config.cpp
./src/linux/config-gtk.cpp
# ./src/linux/ini.c
# ./src/linux/actualfile.c
./src/linux/util.cpp
)
LIST(APPEND SRCS ${SRCS_LINUX})
LIST(APPEND HDRS_QEMU
./src/qemu-usb/input-keymap-linux-to-qcode.h
)
LIST(APPEND SRCS_QEMU
./src/qemu-usb/input-keymap-linux-to-qcode.cpp
)
IF(PLUGIN_BUILD_PULSE)
LIST(APPEND HDRS_MIC
./src/usb-mic/audiodev-pulse.h
)
LIST(APPEND SRCS_MIC
./src/usb-mic/audiodev-pulse.cpp
)
IF(PLUGIN_BUILD_DYNLINK_PULSE)
LIST(APPEND HDRS_MIC
./src/dynlink/pulse.h
)
LIST(APPEND SRCS_MIC
./src/dynlink/pulse.cpp
)
ADD_DEFINITIONS(-DDYNLINK_PULSE=1)
# Reconfiguring triggers rebuild of every file anyway
#SET_SOURCE_FILES_PROPERTIES(./src/usb-mic/audiodev-pulse.cpp PROPERTIES COMPILE_FLAGS -DDYNLINK_PULSE=1)
ELSE(PLUGIN_BUILD_DYNLINK_PULSE)
LIST(APPEND LIBS pulse)
ENDIF(PLUGIN_BUILD_DYNLINK_PULSE)
ENDIF(PLUGIN_BUILD_PULSE)
ADD_DEFINITIONS(-D_GNU_SOURCE -D_USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64)
FIND_PACKAGE(GTK2 REQUIRED)
PKG_CHECK_MODULES(HARFBUZZ harfbuzz)
LIST(APPEND LIBS ${GTK2_LIBRARIES} ${HARFBUZZ_LIBRARIES})
INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${HARFBUZZ_INCLUDE_DIRS})
#LIST(APPEND LIBS Xfixes)
#INCLUDE(FindPkgConfig)
#PKG_CHECK_MODULES(GTK3 gtk+-3.0)
#LIST(APPEND LIBS ${GTK3_LIBRARIES})
#INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
ENDIF()
#
# Now smash it all together
#
SOURCE_GROUP("Header Files" FILES ${HDRS_PLG})
SOURCE_GROUP("Header Files\\linux" FILES ${HDRS_LINUX})
SOURCE_GROUP("Header Files\\Win32" FILES ${HDRS_WIN32})
SOURCE_GROUP("Header Files\\qemu-usb" FILES ${HDRS_QEMU})
SOURCE_GROUP("Header Files\\usb-mic" FILES ${HDRS_MIC})
SOURCE_GROUP("Header Files\\usb-pad" FILES ${HDRS_PAD})
SOURCE_GROUP("Header Files\\usb-msd" FILES ${HDRS_MSD})
SOURCE_GROUP("Header Files\\usb-hid" FILES ${HDRS_HID})
SOURCE_GROUP("Header Files\\usb-eyetoy" FILES ${HDRS_EYETOY})
SOURCE_GROUP("Header Files\\shared" FILES ${HDRS_SHARED})
SOURCE_GROUP("Header Files\\libsamplerate" FILES ${HDRS_SAMPLERATE})
SOURCE_GROUP("Source Files" FILES ${SRCS_PLG})
SOURCE_GROUP("Source Files\\linux" FILES ${SRCS_LINUX})
SOURCE_GROUP("Source Files\\Win32" FILES ${SRCS_WIN32})
SOURCE_GROUP("Source Files\\qemu-usb" FILES ${SRCS_QEMU})
SOURCE_GROUP("Source Files\\usb-mic" FILES ${SRCS_MIC})
SOURCE_GROUP("Source Files\\usb-pad" FILES ${SRCS_PAD})
SOURCE_GROUP("Source Files\\usb-msd" FILES ${SRCS_MSD})
SOURCE_GROUP("Source Files\\usb-hid" FILES ${SRCS_HID})
SOURCE_GROUP("Source Files\\usb-eyetoy" FILES ${SRCS_EYETOY})
SOURCE_GROUP("Source Files\\shared" FILES ${SRCS_SHARED})
SOURCE_GROUP("Source Files\\libsamplerate" FILES ${SRCS_SAMPLERATE})
FOREACH(file ${SRCS_API_INITS})
get_filename_component(api_dir "${file}" DIRECTORY )
get_filename_component(api_dir "${api_dir}" NAME )
SOURCE_GROUP("Source Files\\${api_dir}" FILES "${file}")
ENDFOREACH()
LIST(APPEND HDRS ${HDRS_PLG} ${HDRS_QEMU} ${HDRS_MSD} ${HDRS_MIC} ${HDRS_PAD} ${HDRS_HID} ${HDRS_EYETOY} ${HDRS_SHARED} ${HDRS_SAMPLERATE})
LIST(APPEND SRCS ${SRCS_PLG} ${SRCS_QEMU} ${SRCS_MSD} ${SRCS_MIC} ${SRCS_PAD} ${SRCS_HID} ${SRCS_EYETOY} ${SRCS_SHARED} ${SRCS_API_INITS})
IF(PLUGIN_ENABLE_UNITY_BUILD)
enable_unity_build(${TargetName} SRCS)
enable_unity_build("${TargetName}_libsamplerate" SRCS_SAMPLERATE)
ENDIF(PLUGIN_ENABLE_UNITY_BUILD)
IF(MINGW)
LIST(APPEND LIBS ksguid strmiids)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -static-libgcc -static-libstdc++ -static -lpthread")
ENDIF(MINGW)
if (TOP_CMAKE_WAS_SOURCED)
LIST(APPEND FinalSrcs ${SRCS} ${SRCS_SAMPLERATE} ${HDRS} ${RAW_RCS} ${DX_RCS} ${RCS} ${DEF})
add_pcsx2_plugin(${TargetName} "${FinalSrcs}" "${LIBS}" "${FinalFlags}")
else (TOP_CMAKE_WAS_SOURCED)
IF(UNIX) # hopefully compiling with gcc or the like
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -Wunused-variable -Wno-parentheses")
ENDIF(UNIX)
ADD_LIBRARY(${TargetName} SHARED ${SRCS} ${SRCS_SAMPLERATE} ${HDRS} ${RAW_RCS} ${DX_RCS} ${RCS} ${DEF})
TARGET_LINK_LIBRARIES(${TargetName} ${LIBS})
SET_TARGET_PROPERTIES(${TargetName} PROPERTIES DEBUG_POSTFIX _d)
IF(NOT PACKAGING)
SET_TARGET_PROPERTIES(${TargetName} PROPERTIES OUTPUT_NAME "${TargetNameVer}")
#SET_TARGET_PROPERTIES(${TargetName} PROPERTIES VERSION ${PLUGIN_VERSION} SOVERSION ${PLUGIN_VERSION_MAJOR})
ENDIF(NOT PACKAGING)
# 64 bits specific configuration
IF(NOT PLUGIN_BUILD_64BIT AND CMAKE_SIZEOF_VOID_P MATCHES "8")
#ADD_DEFINITIONS(-m32)
SET_TARGET_PROPERTIES(${TargetName} PROPERTIES COMPILE_FLAGS -m32 LINK_FLAGS -m32 )
ENDIF()
IF(UNIX)
SET_PROPERTY(TARGET ${TargetName} PROPERTY CXX_STANDARD 11)
ENDIF(UNIX)
# post-build copy for win32
IF(WIN32 AND NOT MINGW)
ADD_CUSTOM_COMMAND( TARGET ${TargetName} PRE_BUILD
COMMAND if not exist \"${PROJECT_SOURCE_DIR}\"\\dist mkdir \"${PROJECT_SOURCE_DIR}\"\\dist )
ADD_CUSTOM_COMMAND( TARGET ${TargetName} POST_BUILD
COMMAND copy \"$<SHELL_PATH:$<TARGET_FILE:${TargetName}>>\" \"${PROJECT_SOURCE_DIR}/dist\")
ENDIF(WIN32 AND NOT MINGW)
# set the executable output path for UNIX and MinGW instead of post-build copy
IF(MINGW OR UNIX)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/dist)
ENDIF(MINGW OR UNIX)
# if win32, add INSTALL project -DCMAKE_INSTALL_PREFIX=...\pcsx2\plugins
IF(WIN32)
INSTALL(TARGETS ${TargetName}
RUNTIME DESTINATION .
CONFIGURATIONS Release RelWithDebInfo MinSizeRel Debug) #All
ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wcast-align")
INSTALL(
TARGETS ${TargetName}
LIBRARY DESTINATION .
RUNTIME DESTINATION .
COMPONENT library
)
ENDIF(WIN32)
IF(PACKAGING)
INSTALL(FILES "${CMAKE_SOURCE_DIR}/udev/99-logitech-wheels.rules" DESTINATION "/usr/share/doc/${DEBIAN_PACKAGE}/udev/")
ENDIF(PACKAGING)
endif (TOP_CMAKE_WAS_SOURCED)