forked from GerbilSoft/rom-properties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
381 lines (337 loc) · 11.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
# ROM Properties Page Shell Extension
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
CMAKE_POLICY(SET CMP0048 NEW)
# Read the project version.
CONFIGURE_FILE(version.txt version.txt.tmp)
FILE(STRINGS version.txt RP_VERSION_FILE)
IF(NOT RP_VERSION_FILE)
MESSAGE(FATAL_ERROR "version.txt not found; cannot determine project version.")
ENDIF(NOT RP_VERSION_FILE)
LIST(GET RP_VERSION_FILE 0 RP_VERSION)
UNSET(RP_VERSION_FILE)
PROJECT(rom-properties VERSION ${RP_VERSION})
IF(PROJECT_VERSION_TWEAK)
SET(PROJECT_VERSION_DEVEL_PLUS "+")
ENDIF(PROJECT_VERSION_TWEAK)
MESSAGE(STATUS "ROM Properties Page Shell Extension v${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${PROJECT_VERSION_DEVEL_PLUS}")
# CMAKE_PROJECT_VERSION was introduced in 3.12.
IF(NOT CMAKE_PROJECT_VERSION OR NOT CMAKE_PROJECT_VERSION_MAJOR)
SET(CMAKE_PROJECT_VERSION ${PROJECT_VERSION})
SET(CMAKE_PROJECT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
SET(CMAKE_PROJECT_VERSION_MINOR ${PROJECT_VERSION_MINOR})
SET(CMAKE_PROJECT_VERSION_PATCH ${PROJECT_VERSION_PATCH})
SET(CMAKE_PROJECT_VERSION_TWEAK ${PROJECT_VERSION_TWEAK})
ENDIF(NOT CMAKE_PROJECT_VERSION OR NOT CMAKE_PROJECT_VERSION_MAJOR)
LIST(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake/macros"
"${CMAKE_SOURCE_DIR}/cmake/libs"
)
IF(UNIX AND NOT APPLE)
LIST(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake/macros/GCR_CMake"
)
ENDIF(UNIX AND NOT APPLE)
# If no build type is set, default to "Release".
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" TMP_BUILD_TYPE)
IF(TMP_BUILD_TYPE STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
ELSEIF(TMP_BUILD_TYPE MATCHES "none")
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
ENDIF()
UNSET(TMP_BUILD_TYPE)
# Put all the binaries and libraries into a single directory.
# NOTE: CACHE INTERNAL is required in order to get this to work
# for KF5 for some reason. (and maybe that's why KDE4 did this
# layout by default?)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE INTERNAL "Put all binaries in a single directory.")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE INTERNAL "Put all libraries in a single directory.")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE INTERNAL "Put all archives in a single directory.")
# Enable testing.
# TODO: INCLUDE(CTest) for more advanced testing after
# enough tests are added.
ENABLE_TESTING()
# Set default build options.
INCLUDE(cmake/options.cmake)
# Check for platform-specific functionality.
INCLUDE(cmake/platform.cmake NO_POLICY_SCOPE)
# Program information.
SET(DESCRIPTION "ROM Properties Page shell extension")
SET(PACKAGE_NAME "rom-properties")
SET(AUTHOR "David Korth")
IF(CMAKE_PROJECT_VERSION_PATCH)
SET(VERSION_STRING "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}")
ELSE(CMAKE_PROJECT_VERSION_PATCH)
SET(VERSION_STRING "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}")
ENDIF(CMAKE_PROJECT_VERSION_PATCH)
IF(CMAKE_PROJECT_VERSION_TWEAK)
SET(VERSION_STRING "${VERSION_STRING}+")
ENDIF(CMAKE_PROJECT_VERSION_TWEAK)
SET(VERSION_STRING_WIN32 "${CMAKE_PROJECT_VERSION_MAJOR},${CMAKE_PROJECT_VERSION_MINOR},${CMAKE_PROJECT_VERSION_PATCH},${CMAKE_PROJECT_VERSION_TWEAK}")
# Split Debug function.
# Also sets the image version for Windows builds.
# TODO: Move to SplitDebugInformation.cmake?
FUNCTION(DO_SPLIT_DEBUG _target)
GET_TARGET_PROPERTY(_target_type ${_target} TYPE)
IF(TARGET ${_target} AND NOT _target_type STREQUAL "STATIC_LIBRARY")
# Split debug information.
INCLUDE(SetMSVCDebugPath)
SET_MSVC_DEBUG_PATH(${_target})
IF(SPLIT_DEBUG)
INCLUDE(SplitDebugInformation)
SPLIT_DEBUG_INFORMATION(${_target})
ENDIF(SPLIT_DEBUG)
IF(WIN32)
# Set image version.
# Subprojects can override ${PROJECT_VERSION_MAJOR} and ${PROJECT_VERSION_MINOR}.
# FIXME: If minor version is e.g. "3", Windows interprets it as "03",
# so "1.3" will actually be "1.03".
INCLUDE(Win32ImageVersionLinkerFlags)
IF(PROJECT_VERSION_MAJOR AND PROJECT_VERSION_MINOR)
WIN32_IMAGE_VERSION_LINKER_FLAGS("${PROJECT_VERSION_MAJOR}" "${PROJECT_VERSION_MINOR}")
ELSE()
WIN32_IMAGE_VERSION_LINKER_FLAGS("${CMAKE_PROJECT_VERSION_MAJOR}" "${CMAKE_PROJECT_VERSION_MINOR}")
ENDIF()
ENDIF(WIN32)
ENDIF(TARGET ${_target} AND NOT _target_type STREQUAL "STATIC_LIBRARY")
ENDFUNCTION(DO_SPLIT_DEBUG)
# Git version information.
FIND_PROGRAM(POSIX_SH sh)
IF(POSIX_SH)
# sh is available.
# Run the git version script.
IF(WIN32)
SET(ENV{SHELLOPTS} igncr)
ENDIF(WIN32)
ADD_CUSTOM_TARGET(git_version ALL
${POSIX_SH} "${CMAKE_SOURCE_DIR}/git_version.sh"
-s "${CMAKE_SOURCE_DIR}"
-o "${CMAKE_BINARY_DIR}/git_version.h"
VERBATIM
)
ELSE(POSIX_SH)
# sh isn't available.
# Create a blank git_version.h.
FILE(WRITE "${CMAKE_BINARY_DIR}/git_version.h"
"/* dummy file; POSIX sh is not available */\n")
# Dummy target for dependencies.
ADD_CUSTOM_TARGET(git_version)
ENDIF(POSIX_SH)
# Make sure the file is deleted on `make clean`.
SET_PROPERTY(DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/git_version.h")
# Check for required libraries.
INCLUDE(CheckZLIB)
INCLUDE(CheckPNG)
INCLUDE(CheckJPEG)
INCLUDE(CheckTinyXML2)
INCLUDE(CheckZSTD)
INCLUDE(CheckLZ4)
INCLUDE(CheckLZO)
# Reference: https://cmake.org/Wiki/RecipeAddUninstallTarget
########### Add uninstall target ###############
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
### Subdirectories. ###
IF(ENABLE_NLS)
ADD_SUBDIRECTORY(locale)
ENDIF(ENABLE_NLS)
# Project subdirectories.
ADD_SUBDIRECTORY(extlib)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(xdg)
### Build summary ###
UNSET(UI_FRONTENDS)
IF(BUILD_KDE4)
SET(UI_FRONTENDS "${UI_FRONTENDS} KDE4")
ENDIF(BUILD_KDE4)
IF(BUILD_KF5)
SET(UI_FRONTENDS "${UI_FRONTENDS} KF5")
ENDIF(BUILD_KF5)
IF(BUILD_GTK2)
# NOTE: The GTK+ 2.x plugin is XFCE only right now.
SET(UI_FRONTENDS "${UI_FRONTENDS} XFCE")
ENDIF(BUILD_GTK2)
IF(BUILD_GTK3)
SET(UI_FRONTENDS "${UI_FRONTENDS} GTK3")
ENDIF(BUILD_GTK3)
IF(BUILD_GTK4)
SET(UI_FRONTENDS "${UI_FRONTENDS} GTK4")
ENDIF(BUILD_GTK4)
IF(BUILD_WIN32)
SET(UI_FRONTENDS "${UI_FRONTENDS} Win32")
ENDIF(BUILD_WIN32)
STRING(STRIP "${UI_FRONTENDS}" UI_FRONTENDS)
IF(BUILD_CLI)
SET(CLI_BUILD_MSG "Yes")
ELSE(BUILD_CLI)
SET(CLI_BUILD_MSG "No")
ENDIF(BUILD_CLI)
IF(NOT SECURITY_MECHANISM)
SET(SECURITY_MECHANISM "None")
ENDIF(NOT SECURITY_MECHANISM)
IF(ENABLE_DECRYPTION)
SET(ENABLE_DECRYPTION_MSG "Enabled")
ELSE(ENABLE_DECRYPTION)
SET(ENABLE_DECRYPTION_MSG "Disabled")
ENDIF(ENABLE_DECRYPTION)
IF(ENABLE_XML)
IF(USE_INTERNAL_XML)
SET(ENABLE_XML_MSG "Enabled (bundled)")
ELSE(USE_INTERNAL_XML)
SET(ENABLE_XML_MSG "Enabled (system)")
ENDIF(USE_INTERNAL_XML)
ELSE(ENABLE_XML)
SET(ENABLE_XML_MSG "Disabled")
ENDIF(ENABLE_XML)
IF(ENABLE_PVRTC)
SET(ENABLE_PVRTC_MSG "Enabled")
ELSE(ENABLE_PVRTC)
SET(ENABLE_PVRTC_MSG "Disabled")
ENDIF(ENABLE_PVRTC)
IF(ENABLE_ZSTD)
IF(USE_INTERNAL_ZSTD)
SET(ENABLE_ZSTD_MSG "Enabled (bundled)")
ELSE(USE_INTERNAL_ZSTD)
SET(ENABLE_ZSTD_MSG "Enabled (system)")
ENDIF(USE_INTERNAL_ZSTD)
ELSE(ENABLE_ZSTD)
SET(ENABLE_ZSTD_MSG "Disabled")
ENDIF(ENABLE_ZSTD)
IF(ENABLE_LZ4)
IF(USE_INTERNAL_LZ4)
SET(ENABLE_LZ4_MSG "Enabled (bundled)")
ELSE(USE_INTERNAL_LZ4)
SET(ENABLE_LZ4_MSG "Enabled (system)")
ENDIF(USE_INTERNAL_LZ4)
ELSE(ENABLE_LZ4)
SET(ENABLE_LZ4_MSG "Disabled")
ENDIF(ENABLE_LZ4)
IF(ENABLE_LZO)
IF(USE_INTERNAL_LZO)
SET(ENABLE_LZO_MSG "Enabled (bundled MiniLZO)")
ELSE(USE_INTERNAL_LZO)
SET(ENABLE_LZO_MSG "Enabled (system)")
ENDIF(USE_INTERNAL_LZO)
ELSE(ENABLE_LZO)
SET(ENABLE_LZO_MSG "Disabled")
ENDIF(ENABLE_LZO)
UNSET(EXTLIB_BUILD)
IF(USE_INTERNAL_ZLIB)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - zlib-ng\n")
ENDIF(USE_INTERNAL_ZLIB)
IF(USE_INTERNAL_PNG)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - libpng\n")
ENDIF(USE_INTERNAL_PNG)
IF(USE_INTERNAL_JPEG)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - libjpeg-turbo\n")
ENDIF(USE_INTERNAL_JPEG)
IF(USE_INTERNAL_ZSTD)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - zstd\n")
ENDIF(USE_INTERNAL_ZSTD)
IF(USE_INTERNAL_LZ4)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - lz4\n")
ENDIF(USE_INTERNAL_LZ4)
IF(USE_INTERNAL_LZO)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - MiniLZO\n")
ENDIF(USE_INTERNAL_LZO)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - minizip-ng\n")
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - inih\n")
IF(USE_INTERNAL_XML)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - TinyXML2\n")
ENDIF(USE_INTERNAL_XML)
IF(BUILD_TESTING)
SET(EXTLIB_BUILD "${EXTLIB_BUILD} - Google Test\n")
ENDIF(BUILD_TESTING)
MESSAGE("
*** rom-properties build summary ***
- Building these UI frontends: ${UI_FRONTENDS}
- Building command-line frontend: ${CLI_BUILD_MSG}
- Security mechanism: ${SECURITY_MECHANISM}
- Decryption functionality: ${ENABLE_DECRYPTION_MSG}
- XML parsing: ${ENABLE_XML_MSG}
- PVRTC decoder: ${ENABLE_PVRTC_MSG}
- ZSTD decompression: ${ENABLE_ZSTD_MSG}
- LZ4 decompression: ${ENABLE_LZ4_MSG}
- LZO decompression: ${ENABLE_LZO_MSG}
- Building these third-party libraries from extlib:
${EXTLIB_BUILD}")
IF(NOT UI_FRONTENDS)
MESSAGE(WARNING "*** No UI frontends are being compiled. ***")
IF(NOT BUILD_CLI)
MESSAGE(FATAL_ERROR "*** CLI frontend is not being compiled, either. ***")
ENDIF(NOT BUILD_CLI)
ENDIF(NOT UI_FRONTENDS)
# TODO: Print build summary indicating what plugins will be built.
# (Some other project had something like this...)
# TODO: Fail if no plugins are being built.
### CPack ###
# CPack settings.
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${DESCRIPTION}")
SET(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
SET(CPACK_PACKAGE_VENDOR "${AUTHOR}")
SET(CPACK_PACKAGE_CONTACT "David Korth <gerbilsoft@gerbilsoft.com>")
SET(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
SET(CPACK_PACKAGE_VERSION_TWEAK ${CMAKE_PROJECT_VERSION_TWEAK})
SET(CPACK_PACKAGE_VERSION ${VERSION_STRING})
# TODO: DESCRIPTION and WELCOME files.
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/doc/DESCRIPTION.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
#SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/doc/WELCOME.txt")
# Additional document files for the root directory.
# TODO: Convert from Unix line endings to Windows when
# compiling for Windows?
INCLUDE(DirInstallPaths)
INSTALL(FILES NETWORK.md
DESTINATION "${DIR_INSTALL_DOC_ROOT}"
COMPONENT "doc"
)
# CPack: Source package settings.
# NOTE: Double-escape is required because the unescaped
# string # is written to CPackSourceConfig.cmake, which
# is then unescaped.
SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_SOURCE_IGNORE_FILES
"build.*/"
"build.*\\\\.sh"
"\\\\.git/"
"\\\\.gitignore"
"*\\\\.kate-swp"
)
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.|x)86\$")
SET(CPACK_PACKAGE_SYSTEM_PROCESSOR "i386")
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64\$")
SET(CPACK_PACKAGE_SYSTEM_PROCESSOR "amd64")
ELSE()
SET(CPACK_PACKAGE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
ENDIF()
IF(APPLE)
# TODO: Support for Mac OS X.
ELSEIF(WIN32)
IF(MSVC AND CMAKE_CL_64)
SET(WIN32_PACKAGE_SUFFIX "win64")
ELSEIF(NOT MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(WIN32_PACKAGE_SUFFIX "win64")
ELSE()
SET(WIN32_PACKAGE_SUFFIX "win32")
ENDIF()
SET(CPACK_GENERATOR "ZIP")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${WIN32_PACKAGE_SUFFIX}")
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
ENDIF()
# Components.
SET(CPACK_COMPONENTS_ALL dll program debug doc i18n)
SET(CPACK_COMPONENT_DLL_DISPLAY_NAME "DLLs")
SET(CPACK_COMPONENT_PROGRAM_DISPLAY_NAME "Programs")
SET(CPACK_COMPONENT_DEBUG_DISPLAY_NAME "Debugging Symbols")
SET(CPACK_COMPONENT_DOC_DISPLAY_NAME "Documents")
SET(CPACK_COMPONENT_I18N_DISPLAY_NAME "Internationalization")
# Initialize CPack.
INCLUDE(CPack)