-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
202 lines (180 loc) · 7.03 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
PROJECT(mcrecover_base)
# CMake 2.8.11 adds TARGET_INCLUDE_DIRECTORIES() and Qt4::xxx targets, similar to Qt5.
# CMake 2.8.12 automates adding compile flags for Qt5, e.g. -fPIC on Linux.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
LIST(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake/macros"
"${CMAKE_SOURCE_DIR}/cmake/modules"
"${CMAKE_SOURCE_DIR}/cmake/libs"
)
# If no build type is set, default to "Debug".
# TODO: Default to "Release"?
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" TMP_BUILD_TYPE)
IF(TMP_BUILD_TYPE STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release")
ELSEIF(TMP_BUILD_TYPE MATCHES "none")
SET(CMAKE_BUILD_TYPE "Release")
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 KDE5 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.")
# Set default build options.
INCLUDE(cmake/options.cmake)
# Check for platform-specific functionality.
INCLUDE(cmake/platform.cmake NO_POLICY_SCOPE)
# Program information.
SET(DESCRIPTION "GCN MemCard Recover")
SET(PACKAGE_NAME "mcrecover")
SET(AUTHOR "David Korth")
SET(VERSION_MAJOR 0)
SET(VERSION_MINOR 2)
SET(VERSION_PATCH 1)
SET(VERSION_DEVEL 1)
IF(VERSION_PATCH)
SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
ELSE(VERSION_PATCH)
SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}")
ENDIF(VERSION_PATCH)
IF(VERSION_DEVEL)
SET(VERSION_STRING "${VERSION_STRING}+")
ENDIF(VERSION_DEVEL)
SET(VERSION_STRING_WIN32 "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_DEVEL}")
# Split Debug macro.
# Also sets the image version for Windows builds.
INCLUDE(Win32ImageVersionLinkerFlags)
MACRO(DO_SPLIT_DEBUG _target)
IF(TARGET ${_target})
# Split debug information.
INCLUDE(SetMSVCDebugPath)
SET_MSVC_DEBUG_PATH(${_target})
IF(SPLIT_DEBUG)
INCLUDE(SplitDebugInformation)
SPLIT_DEBUG_INFORMATION(${_target})
ENDIF(SPLIT_DEBUG)
# Set image version.
# Subprojects can override ${VERSION_MAJOR} and ${VERSION_MINOR}.
# FIXME: If minor version is e.g. "3", Windows interprets it as "03",
# so "1.3" will actually be "1.03".
# TODO: Don't do this for extlib if building DLLs?
WIN32_IMAGE_VERSION_LINKER_FLAGS(${VERSION_MAJOR} ${VERSION_MINOR})
ENDIF(TARGET ${_target})
ENDMACRO(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.
# NOTE: This has to be done here in addition to
# the project subdirectories; otherwise, the
# results may be lost.
INCLUDE(CheckPNG)
INCLUDE(CheckGIF)
# 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. ###
# Translations.
IF(ENABLE_NLS)
# NOTE: ENABLE_NLS only controls whether or not translations
# are built. TranslationManager and related are always built
# regardless.
ADD_SUBDIRECTORY(locale)
ENDIF(ENABLE_NLS)
# Project subdirectories.
ADD_SUBDIRECTORY(extlib)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(data)
ADD_SUBDIRECTORY(doc)
# 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 <[email protected]>")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_PACKAGE_VERSION ${VERSION_STRING})
# CPack: Debian package settings.
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.4), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.1.1), libqtcore4 (>= 4:4.6.0), libqt4-xml (>= 4:4.6.0), libqtgui4 (>= 4:4.6.0), libpcre3")
SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "libqt4-dev (>= 4:4.6.0), libpcre3-dev")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_DEBIAN_PACKAGE_SECTION "games")
SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
# TODO: DESCRIPTION and WELCOME files.
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/doc/DESCRIPTION.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/doc/gpl-2.0.txt")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/doc/README.txt")
#SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/doc/WELCOME.txt")
# 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"
"FOR FUTURE USE/"
".kdev4/"
)
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(UNIX AND NOT APPLE)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_PACKAGE_SYSTEM_PROCESSOR}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}")
ELSEIF(APPLE)
# (TODO for mcrecover-v0.3)
ELSEIF(WIN32)
SET(CPACK_GENERATOR "ZIP")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-win32")
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
ENDIF()
# Components.
SET(CPACK_COMPONENTS_ALL program debug database translations doc desktop-icon)
SET(CPACK_COMPONENT_PROGRAM_DISPLAY_NAME "Programs")
SET(CPACK_COMPONENT_DEBUG_DISPLAY_NAME "Debugging Symbols")
SET(CPACK_COMPONENT_DATABASE_DISPLAY_NAME "Memory Card File Databases")
SET(CPACK_COMPONENT_TRANSLATIONS_DISPLAY_NAME "Translations")
SET(CPACK_COMPONENT_DOC_DISPLAY_NAME "Documentation")
SET(CPACK_COMPONENT_DESKTOP-ICON_DISPLAY_NAME "XDG Desktop File")
# Initialize CPack.
# FIXME: Use a debian/ directory instead of cpack.
#INCLUDE(CPack)