-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
249 lines (217 loc) · 8.53 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
cmake_minimum_required(VERSION 3.5.0)
project(ECWolf)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
include(src/versiondefs.cmake)
# We need a newer CPack version to get desirable results.
# Note: CMake 3.11+ recommended for best results
if(NOT CMAKE_VERSION VERSION_LESS "3.6.0")
set(USE_CPACK ON)
else()
set(USE_CPACK OFF)
endif()
if(USE_CPACK)
set(CPACK_PACKAGE_CONTACT "First Last <[email protected]>" CACHE STRING "Contact info for archive maintainer.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Advanced source port of the Wolfenstein 3D engine.\n Provides enhanced game engine for playing Wolfenstein 3D, Spear of Destiny, and\n Super 3-D Noah's Ark. Requires the original game data files.")
string(TOLOWER "${PRODUCT_NAME}" CPACK_PACKAGE_NAME)
# Use same prefix for packaging for consistency
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(CPACK_STRIP_FILES ON)
set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CPackProjectConfig.cmake")
if(WIN32)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "DEB")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://maniacsvault.net/ecwolf/")
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION ON)
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
endif()
include(CPack)
endif()
# Multiarch support
if(UNIX AND NOT APPLE)
# We are in the games section
set(CMAKE_INSTALL_BINDIR "games")
include(GNUInstallDirs)
if(CPACK_PACKAGE_NAME)
# Match this to package name instead of project name
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${CPACK_PACKAGE_NAME}")
endif()
# GNUInstallDirs doesn't provide this, but we could use share/product_name
set(CMAKE_INSTALL_DATAPRODUCTDIR "${CMAKE_INSTALL_DATADIR}/${PRODUCT_DIRECTORY}")
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
# CMAKE_ prefix used here to match the variable set by GNUInstallDirs.
# Value currently doesn't matter outside of Linux these are more or less
# to keep the script working where values are expected.
if(NOT WIN32)
set(CMAKE_INSTALL_BINDIR "bin")
set(CMAKE_INSTALL_DATAROOTDIR "share")
set(CMAKE_INSTALL_LIBDIR "lib")
set(CMAKE_INSTALL_MANDIR "share/man")
set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
set(CMAKE_INSTALL_DATAPRODUCTDIR "${CMAKE_INSTALL_DATADIR}/${PRODUCT_DIRECTORY}")
if(CPACK_PACKAGE_NAME)
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${CPACK_PACKAGE_NAME}")
else()
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PRODUCT_DIRECTORY}")
endif()
else()
set(CMAKE_INSTALL_BINDIR ".")
set(CMAKE_INSTALL_DATAROOTDIR ".")
set(CMAKE_INSTALL_LIBDIR ".")
set(CMAKE_INSTALL_MANDIR ".")
set(CMAKE_INSTALL_DATADIR ".")
set(CMAKE_INSTALL_DATAPRODUCTDIR ".")
set(CMAKE_INSTALL_DOCDIR ".")
endif()
endif()
# Support cross compiling
option( FORCE_CROSSCOMPILE "Turn on cross compiling." NO )
if( FORCE_CROSSCOMPILE )
set( CMAKE_CROSSCOMPILING TRUE )
endif()
if(CMAKE_CROSSCOMPILING AND NOT LIBRETRO)
set(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Export file from native build.")
include(${IMPORT_EXECUTABLES})
endif()
# Replacement variables for a possible long list of C/C++ compilers compatible with GCC
if( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" )
set( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE TRUE )
else()
set( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE FALSE )
endif()
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
set( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE TRUE )
else()
set( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE FALSE )
endif()
# Simplify pk3 building, add_pk3(filename srcdirectory)
function( add_pk3 PK3_NAME PK3_DIR )
# Generate target name. Just use "pk3" for main pk3 target.
string( REPLACE "." "_" PK3_TARGET ${PK3_NAME} )
if( ${PK3_TARGET} STREQUAL "ecwolf_pk3" )
set( PK3_TARGET "pk3" )
endif()
# Touch the zipdir executable here so that the pk3s are forced to rebuild
# each time since their dependecy has "changed."
if( LIBRETRO )
set(TARGET_DIR "$<TARGET_FILE_DIR:ecwolf_libretro>")
add_custom_target( ${PK3_TARGET} ALL
COMMAND zipdir -udf $<TARGET_FILE_DIR:ecwolf_libretro>/${PK3_NAME} ${PK3_DIR}
DEPENDS zipdir )
install(FILES ${TARGET_DIR}/${PK3_NAME} DESTINATION "${CMAKE_INSTALL_DATAPRODUCTDIR}")
elseif( NOT ANDROID )
set(TARGET_DIR "$<TARGET_FILE_DIR:engine>")
add_custom_target( ${PK3_TARGET} ALL
COMMAND zipdir -udf $<TARGET_FILE_DIR:engine>/${PK3_NAME} ${PK3_DIR}
DEPENDS zipdir )
install(FILES ${TARGET_DIR}/${PK3_NAME} DESTINATION "${CMAKE_INSTALL_DATAPRODUCTDIR}")
else()
# On Android need to put pk3 in an assets directory
add_custom_target( ${PK3_TARGET} ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_DIR}/assets
COMMAND zipdir -udf ${OUTPUT_DIR}/assets/${PK3_NAME} ${PK3_DIR}
DEPENDS zipdir )
endif()
endfunction()
set(OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory in which to build ECWolf.")
option(GPL "Build GPL edition" ON)
option(USE_LIBTEXTSCREEN "Use libtextscreen instead of console iwad picker." OFF)
option(INTERNAL_ZLIB "Force build with internal zlib" OFF)
option(INTERNAL_BZIP2 "Force build with internal bzip2" OFF)
option(INTERNAL_JPEG "Force build with internal libjpeg" OFF)
if(LIBRETRO)
set(INTERNAL_JPEG ON)
set(INTERNAL_BZIP2 ON)
set(INTERNAL_ZLIB ON)
endif()
if(NOT INTERNAL_ZLIB)
find_package(ZLIB QUIET)
endif()
if(NOT INTERNAL_BZIP2)
find_package(BZip2 QUIET)
endif()
if(NOT INTERNAL_JPEG)
find_package(JPEG QUIET)
endif()
if(NOT ZLIB_FOUND OR INTERNAL_ZLIB)
message(STATUS "Using internal zlib")
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/zlib)
add_subdirectory(deps/zlib)
set(ZLIB_LIBRARIES ZLIB::ZLIB)
set(ZLIB_LIBRARY ZLIB::ZLIB)
else()
message(STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIR}")
endif()
if(NOT BZIP2_FOUND OR INTERNAL_BZIP2)
message(STATUS "Using internal libbz2")
set(BZIP2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2)
add_subdirectory(deps/bzip2)
set(BZIP2_LIBRARIES bz2)
else()
message(STATUS "Using system libbz2, includes found at ${BZIP2_INCLUDE_DIR}")
endif()
if(NOT JPEG_FOUND OR INTERNAL_JPEG)
message(STATUS "Using internal libjpeg")
set(JPEG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/jpeg-6b)
add_subdirectory(deps/jpeg-6b)
set(JPEG_LIBRARIES jpeg)
set(JPEG_LIBRARY jpeg)
else()
message(STATUS "Using system libjpeg, includes found at ${JPEG_INCLUDE_DIR}")
endif()
if(NOT LIBRETRO)
include(LocateSDL2.cmake)
endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
endif()
add_subdirectory(tools/zipdir)
add_subdirectory(tools/updaterevision)
if(NOT LIBRETRO)
add_subdirectory(deps/gdtoa)
endif()
add_subdirectory(deps/lzma)
if(GPL AND USE_LIBTEXTSCREEN)
add_subdirectory(deps/textscreen)
endif()
if(ANDROID AND NOT LIBRETRO)
set(LIBPNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android-libs)
set(LIBPNG_LIBRARY png16_static)
add_subdirectory(android-libs/libpng)
add_subdirectory(android-libs/sigc++)
add_subdirectory(android-libs/TinyXML)
add_subdirectory(android-libs/TouchControls)
add_subdirectory(android-libs/launcher)
endif()
add_subdirectory(src)
if (NOT CMAKE_CROSSCOMPILING OR NOT LIBRETRO)
add_subdirectory(wadsrc)
endif()
if(USE_CPACK AND NOT APPLE)
if(WIN32)
install(FILES docs/copyright DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME licenses.txt)
else()
install(FILES docs/copyright DESTINATION "${CMAKE_INSTALL_DOCDIR}")
install(FILES docs/changelog DESTINATION "${CMAKE_INSTALL_DOCDIR}")
install(FILES docs/ecwolf.6 DESTINATION "${CMAKE_INSTALL_MANDIR}/man6")
# Lintian requires that man pages in deb packages are compressed.
find_program(GZIP_BINARY NAMES gzip DOC "gzip program for man page compression.")
if(GZIP_BINARY)
install(CODE "execute_process(COMMAND \"${GZIP_BINARY}\" -fn9 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}/changelog\")")
install(CODE "execute_process(COMMAND \"${GZIP_BINARY}\" -fn9 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_MANDIR}/man6/ecwolf.6\")")
endif()
endif()
endif()
if( NOT CMAKE_CROSSCOMPILING )
export(TARGETS ${CROSS_EXPORTS} FILE "${CMAKE_BINARY_DIR}/ImportExecutables.cmake" )
endif()