all repos — mgba @ ae721309d0865f014914085e44412af6be10728c

mGBA Game Boy Advance Emulator

CMakeLists.txt (view raw)

  1cmake_minimum_required(VERSION 2.6)
  2project(mGBA C)
  3set(BINARY_NAME mgba CACHE INTERNAL "Name of output binaries")
  4if(NOT MSVC)
  5	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99")
  6else()
  7	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146")
  8endif()
  9set(USE_CLI_DEBUGGER ON CACHE BOOL "Whether or not to enable the CLI-mode ARM debugger")
 10set(USE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger")
 11set(USE_FFMPEG ON CACHE BOOL "Whether or not to enable FFmpeg support")
 12set(USE_ZLIB ON CACHE BOOL "Whether or not to enable zlib support")
 13set(USE_MINIZIP ON CACHE BOOL "Whether or not to enable external minizip support")
 14set(USE_PNG ON CACHE BOOL "Whether or not to enable PNG support")
 15set(USE_LIBZIP ON CACHE BOOL "Whether or not to enable LIBZIP support")
 16set(USE_MAGICK ON CACHE BOOL "Whether or not to enable ImageMagick support")
 17set(M_CORE_GBA ON CACHE BOOL "Build Game Boy Advance core")
 18set(M_CORE_GB ON CACHE BOOL "Build Game Boy core")
 19set(USE_LZMA ON CACHE BOOL "Whether or not to enable 7-Zip support")
 20set(BUILD_QT ON CACHE BOOL "Build Qt frontend")
 21set(BUILD_SDL ON CACHE BOOL "Build SDL frontend")
 22set(BUILD_LIBRETRO OFF CACHE BOOL "Build libretro core")
 23if(APPLE)
 24	set(BUILD_OPENEMU OFF CACHE BOOL "Build OpenEmu core")
 25endif()
 26set(BUILD_PERF OFF CACHE BOOL "Build performance profiling tool")
 27set(BUILD_TEST OFF CACHE BOOL "Build testing harness")
 28set(BUILD_EXAMPLE OFF CACHE BOOL "Build example frontends")
 29set(BUILD_STATIC OFF CACHE BOOL "Build a static library")
 30set(BUILD_SHARED ON CACHE BOOL "Build a shared library")
 31set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)")
 32set(BUILD_GL ON CACHE STRING "Build with OpenGL")
 33set(BUILD_GLES2 OFF CACHE STRING "Build with OpenGL|ES 2")
 34set(USE_EPOXY ON CACHE STRING "Build with libepoxy")
 35set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies")
 36file(GLOB ARM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/arm/*.c)
 37file(GLOB LR35902_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/*.c)
 38file(GLOB GBA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/*.c)
 39file(GLOB GB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/*.c)
 40file(GLOB GBA_CHEATS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/cheats/*.c)
 41file(GLOB GBA_RR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/rr/*.c)
 42file(GLOB GBA_EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/extra/*.c)
 43file(GLOB UTIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/*.[cSs] ${CMAKE_CURRENT_SOURCE_DIR}/src/core/*.c)
 44file(GLOB GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/gui/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/feature/gui/*.c)
 45file(GLOB GBA_RENDERER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/renderers/*.c)
 46file(GLOB SIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/sio/lockstep.c)
 47file(GLOB GB_RENDERER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/renderers/*.c)
 48file(GLOB THIRD_PARTY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/inih/*.c)
 49set(CLI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/feature/commandline.c)
 50set(CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-mem.c)
 51set(VFS_SRC)
 52source_group("ARM core" FILES ${ARM_SRC})
 53source_group("LR35902 core" FILES ${LR35902_SRC})
 54source_group("GBA board" FILES ${GBA_SRC} ${GBA_RENDERER_SRC} ${SIO_SRC})
 55source_group("GBA extra" FILES ${GBA_CHEATS_SRC} ${GBA_EXTRA_SRC} ${GBA_RR_SRC})
 56source_group("GB board" FILES ${GB_SRC})
 57source_group("Utilities" FILES ${UTIL_SRC})
 58include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
 59
 60if(NOT CMAKE_BUILD_TYPE)
 61	set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (e.g. Release or Debug)" FORCE)
 62endif()
 63
 64include(GNUInstallDirs)
 65
 66if (NOT DEFINED LIBDIR)
 67	set(LIBDIR "${CMAKE_INSTALL_LIBDIR}")
 68endif()
 69
 70set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
 71
 72if (NOT DEFINED MANDIR)
 73	set(MANDIR ${CMAKE_INSTALL_MANDIR})
 74endif()
 75
 76# Function definitions
 77include(FindPkgConfig)
 78function(find_feature FEATURE_NAME FEATURE_REQUIRES)
 79	if (NOT ${FEATURE_NAME})
 80		return()
 81	endif()
 82	if (DISABLE_DEPS)
 83		set(${FEATURE_NAME} OFF PARENT_SCOPE)
 84		return()
 85	endif()
 86	foreach(REQUIRE ${FEATURE_REQUIRES})
 87		if(NOT ${REQUIRE}_FOUND)
 88			find_package(${REQUIRE} QUIET)
 89			if(NOT ${REQUIRE}_FOUND)
 90				pkg_search_module(${REQUIRE} ${REQUIRE})
 91				if (NOT ${REQUIRE}_FOUND)
 92					message(WARNING "Requested module ${REQUIRE} missing for feature ${FEATURE_NAME}. Feature disabled.")
 93					set(${FEATURE_NAME} OFF PARENT_SCOPE)
 94					return()
 95				endif()
 96			endif()
 97		endif()
 98		string(TOUPPER ${REQUIRE} UREQUIRE)
 99		set(${UREQUIRE}_CFLAGS_OTHER ${${REQUIRE}_CFLAGS_OTHER} PARENT_SCOPE)
100		set(${UREQUIRE}_FOUND ${${REQUIRE}_FOUND} PARENT_SCOPE)
101		set(${UREQUIRE}_INCLUDE_DIRS ${${REQUIRE}_INCLUDE_DIRS} PARENT_SCOPE)
102		set(${UREQUIRE}_LIBRARIES ${${REQUIRE}_LIBRARIES} PARENT_SCOPE)
103		set(${UREQUIRE}_LIBRARY_DIRS ${${REQUIRE}_LIBRARY_DIRS} PARENT_SCOPE)
104		set(${UREQUIRE}_LDFLAGS_OTHER ${${REQUIRE}_LDFLAGS_OTHER} PARENT_SCOPE)
105	endforeach()
106endfunction()
107
108# Version information
109add_custom_target(version-info ALL ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/src/core/version.c.in
110	COMMAND ${CMAKE_COMMAND}
111	-DBINARY_NAME=${BINARY_NAME}
112	-DCONFIG_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/core/version.c.in
113	-DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.c
114	-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
115	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
116
117include(${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
118configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/core/version.c.in ${CMAKE_CURRENT_BINARY_DIR}/version.c)
119list(APPEND UTIL_SRC ${CMAKE_CURRENT_BINARY_DIR}/version.c)
120source_group("Generated sources" FILES ${CMAKE_CURRENT_BINARY_DIR}/version.c)
121
122# Advanced settings
123set(BUILD_LTO ON CACHE BOOL "Build with link-time optimization")
124set(BUILD_PGO OFF CACHE BOOL "Build with profiling-guided optimization")
125set(PGO_STAGE_2 CACHE BOOL "Rebuild for profiling-guided optimization after profiles have been generated")
126set(PGO_DIR "/tmp/gba-pgo/" CACHE PATH "Profiling-guided optimization profiles path")
127mark_as_advanced(BUILD_LTO BUILD_PGO PGO_STAGE_2 PGO_DIR)
128set(PGO_PRE_FLAGS "-fprofile-generate=${PGO_DIR} -fprofile-arcs")
129set(PGO_POST_FLAGS "-fprofile-use=${PGO_DIR} -fbranch-probabilities")
130
131if(BUILD_PGO AND NOT PGO_STAGE_2)
132	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${PGO_PRE_FLAGS}")
133	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PGO_PRE_FLAGS}")
134	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PGO_PRE_FLAGS}")
135elseif(BUILD_PGO AND PGO_STAGE_2)
136	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${PGO_POST_FLAGS}")
137	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PGO_POST_FLAGS}")
138	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PGO_POST_FLAGS}")
139endif()
140
141# Platform support
142if(WIN32)
143	set(WIN32_VERSION "${LIB_VERSION_MAJOR},${LIB_VERSION_MINOR},${LIB_VERSION_PATCH}")
144	add_definitions(-D_WIN32_WINNT=0x0600)
145	list(APPEND OS_LIB ws2_32 shlwapi)
146	list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-fd.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/windows/vfs-w32.c)
147	file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/windows/*.c)
148	source_group("Windows-specific code" FILES ${OS_SRC})
149	if(MSVC)
150		add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
151	endif()
152elseif(UNIX)
153	add_definitions(-DUSE_PTHREADS)
154
155	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
156		add_definitions(-D_GNU_SOURCE)
157	endif()
158	if(NOT APPLE AND NOT HAIKU)
159		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
160	endif()
161
162	list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-fd.c ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
163	file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/posix/*.c)
164	source_group("POSIX-specific code" FILES ${OS_SRC})
165endif()
166
167if(APPLE)
168	add_definitions(-D_DARWIN_C_SOURCE)
169	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.6")
170endif()
171
172if(NOT HAIKU AND NOT MSVC AND NOT PSP2)
173	set(M_LIBRARY m)
174endif()
175list(APPEND OS_LIB ${M_LIBRARY})
176
177if(APPLE OR CMAKE_C_COMPILER_ID STREQUAL "GNU" AND BUILD_LTO)
178	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
179	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
180endif()
181
182if(BUILD_BBB OR BUILD_RASPI OR BUILD_PANDORA)
183	if(NOT BUILD_EGL)
184		add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
185	endif()
186endif()
187
188if(BUILD_RASPI)
189	set(BUILD_GL OFF CACHE BOOL "OpenGL not supported" FORCE)
190endif()
191
192if(BUILD_PANDORA)
193	add_definitions(-DBUILD_PANDORA)
194endif()
195
196if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*")
197	enable_language(ASM)
198endif()
199
200if(PSP2 OR WII)
201	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
202endif()
203
204if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII)
205	set(USE_GDB_STUB OFF)
206endif()
207
208if(WII)
209	add_definitions(-U__STRICT_ANSI__)
210endif()
211
212include(CheckFunctionExists)
213check_function_exists(strdup HAVE_STRDUP)
214check_function_exists(strndup HAVE_STRNDUP)
215check_function_exists(localtime_r HAVE_LOCALTIME_R)
216if(NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
217	check_function_exists(snprintf_l HAVE_SNPRINTF_L)
218	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
219		# The strtof_l on Linux not actually exposed nor actually strtof_l
220		set(HAVE_STRTOF_L OFF)
221	else()
222		check_function_exists(strtof_l HAVE_STRTOF_L)
223	endif()
224	check_function_exists(newlocale HAVE_NEWLOCALE)
225	check_function_exists(freelocale HAVE_FREELOCALE)
226	check_function_exists(uselocale HAVE_USELOCALE)
227	check_function_exists(setlocale HAVE_SETLOCALE)
228else()
229	if(NOT DEFINED 3DS AND NOT DEFINED PSP2 AND NOT DEFINED WII)
230		set(DISABLE_DEPS ON CACHE BOOL "This platform cannot build with dependencies" FORCE)
231	endif()
232	set(DISABLE_FRONTENDS ON)
233	set(MINIMAL_CORE ON)
234endif()
235
236check_function_exists(chmod HAVE_CHMOD)
237check_function_exists(umask HAVE_UMASK)
238
239set(FUNCTION_DEFINES)
240
241if(HAVE_STRDUP)
242	list(APPEND FUNCTION_DEFINES HAVE_STRDUP)
243endif()
244
245if(HAVE_STRNDUP)
246	list(APPEND FUNCTION_DEFINES HAVE_STRNDUP)
247endif()
248
249if(HAVE_LOCALTIME_R)
250	list(APPEND FUNCTION_DEFINES HAVE_LOCALTIME_R)
251endif()
252
253if(HAVE_NEWLOCALE AND HAVE_FREELOCALE AND HAVE_USELOCALE OR APPLE)
254	list(APPEND FUNCTION_DEFINES HAVE_LOCALE)
255	if (HAVE_STRTOF_L)
256		list(APPEND FUNCTION_DEFINES HAVE_STRTOF_L)
257	endif()
258	if (HAVE_SNPRINTF_L)
259		list(APPEND FUNCTION_DEFINES HAVE_SNPRINTF_L)
260	endif()
261endif()
262
263if(HAVE_SETLOCALE)
264	list(APPEND FUNCTION_DEFINES HAVE_SETLOCALE)
265endif()
266
267if(HAVE_CHMOD)
268	list(APPEND FUNCTION_DEFINES HAVE_CHMOD)
269endif()
270
271if(HAVE_UMASK)
272	list(APPEND FUNCTION_DEFINES HAVE_UMASK)
273endif()
274
275# Feature dependencies
276set(FEATURES)
277if(CMAKE_SYSTEM_NAME MATCHES .*BSD)
278	set(LIBEDIT_LIBRARIES -ledit)
279	if (CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
280		list(APPEND LIBEDIT_LIBRARIES -ltermcap)
281	endif()
282else()
283	find_feature(USE_CLI_DEBUGGER "libedit")
284endif()
285if(BUILD_GL)
286	find_package(OpenGL QUIET)
287	if(NOT OPENGL_FOUND)
288		set(BUILD_GL OFF CACHE BOOL "OpenGL not found" FORCE)
289	endif()
290endif()
291if(NOT BUILD_GL)
292	set(OPENGLE_LIBRARY "" CACHE PATH "" FORCE)
293endif()
294if(BUILD_GLES2 AND NOT BUILD_RASPI)
295	find_path(OPENGLES2_INCLUDE_DIR NAMES GLES2/gl2.h)
296	find_library(OPENGLES2_LIBRARY NAMES GLESv2 GLESv2_CM)
297	if(NOT OPENGLES2_INCLUDE_DIR OR NOT OPENGLES2_LIBRARY)
298		set(BUILD_GLES2 OFF CACHE BOOL "OpenGL|ES 2 not found" FORCE)
299	endif()
300endif()
301if(NOT BUILD_GLES2)
302	set(OPENGLES2_LIBRARY "" CACHE PATH "" FORCE)
303endif()
304set(WANT_ZLIB ${USE_ZLIB})
305set(WANT_PNG ${USE_PNG})
306set(WANT_LIBZIP ${USE_LIBZIP})
307
308find_feature(USE_FFMPEG "libavcodec;libavformat;libavresample;libavutil;libswscale")
309find_feature(USE_ZLIB "ZLIB")
310find_feature(USE_MINIZIP "minizip")
311find_feature(USE_PNG "PNG")
312find_feature(USE_LIBZIP "libzip")
313find_feature(USE_MAGICK "MagickWand")
314find_feature(USE_EPOXY "epoxy")
315
316# Features
317set(DEBUGGER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/debugger.c)
318set(FEATURE_SRC)
319set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
320
321if(DISABLE_DEPS)
322	set(USE_GDB_STUB OFF)
323endif()
324
325if(USE_CLI_DEBUGGER)
326	list(APPEND FEATURES CLI_DEBUGGER)
327	list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/cli-debugger.c)
328	list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/parser.c)
329	if(M_CORE_GBA)
330		list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/arm/debugger/cli-debugger.c)
331		list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/extra/cli.c)
332	endif()
333	if(M_CORE_GB)
334		list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/debugger/cli-debugger.c)
335	endif()
336	include_directories(AFTER ${LIBEDIT_INCLUDE_DIRS})
337	link_directories(${LIBEDIT_LIBRARY_DIRS})
338	set(DEBUGGER_LIB ${LIBEDIT_LIBRARIES})
339	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libedit2")
340else()
341	set(DEBUGGER_LIB "")
342endif()
343
344if(USE_GDB_STUB)
345	list(APPEND FEATURES GDB_STUB)
346	list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/gdb-stub.c)
347endif()
348source_group("Debugger" FILES ${DEBUGGER_SRC})
349
350if(USE_FFMPEG)
351	list(APPEND FEATURES FFMPEG)
352	pkg_search_module(LIBSWRESAMPLE QUIET libswresample)
353	if(NOT LIBSWRESAMPLE_FOUND)
354		list(APPEND FEATURES LIBAV)
355	endif()
356	include_directories(AFTER ${LIBAVCODEC_INCLUDE_DIRS} ${LIBAVFORMAT_INCLUDE_DIRS} ${LIBAVRESAMPLE_INCLUDE_DIRS} ${LIBAVUTIL_INCLUDE_DIRS} ${LIBSWSCALE_INCLUDE_DIRS})
357	link_directories(${LIBAVCODEC_LIBRARY_DIRS} ${LIBAVFORMAT_LIBRARY_DIRS} ${LIBAVRESAMPLE_LIBRARY_DIRS} ${LIBAVUTIL_LIBRARY_DIRS} ${LIBSWSCALE_LIBRARY_DIRS})
358	list(APPEND FEATURE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/feature/ffmpeg/ffmpeg-encoder.c")
359	string(REGEX MATCH "^[0-9]+" LIBAVCODEC_VERSION_MAJOR ${libavcodec_VERSION})
360	string(REGEX MATCH "^[0-9]+" LIBAVFORMAT_VERSION_MAJOR ${libavformat_VERSION})
361	string(REGEX MATCH "^[0-9]+" LIBAVRESAMPLE_VERSION_MAJOR ${libavresample_VERSION})
362	string(REGEX MATCH "^[0-9]+" LIBAVUTIL_VERSION_MAJOR ${libavutil_VERSION})
363	string(REGEX MATCH "^[0-9]+" LIBSWSCALE_VERSION_MAJOR ${libswscale_VERSION})
364	list(APPEND DEPENDENCY_LIB ${LIBAVCODEC_LIBRARIES} ${LIBAVFORMAT_LIBRARIES} ${LIBAVRESAMPLE_LIBRARIES} ${LIBAVUTIL_LIBRARIES} ${LIBSWSCALE_LIBRARIES})
365	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libavcodec${LIBAVCODEC_VERSION_MAJOR}|libavcodec-extra-${LIBAVCODEC_VERSION_MAJOR}|libavcodec-ffmpeg${LIBAVCODEC_VERSION_MAJOR}|libavcodec-ffmpeg-extra${LIBAVCODEC_VERSION_MAJOR}")
366	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libavformat${LIBAVFORMAT_VERSION_MAJOR}|libavformat-ffmpeg${LIBAVFORMAT_VERSION_MAJOR}")
367	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libavresample${LIBAVRESAMPLE_VERSION_MAJOR}|libavresample-ffmpeg${LIBAVRESAMPLE_VERSION_MAJOR}")
368	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libavutil${LIBAVUTIL_VERSION_MAJOR}|libavutil-ffmpeg${LIBAVUTIL_VERSION_MAJOR}")
369	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libswscale${LIBSWSCALE_VERSION_MAJOR}|libswscale-ffmpeg${LIBSWSCALE_VERSION_MAJOR}")
370	set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libavcodec-extra|libavcodec-ffmpeg-extra${LIBAVCODEC_VERSION_MAJOR}")
371	if(APPLE)
372		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework VideoDecodeAcceleration -framework CoreVideo")
373		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework VideoDecodeAcceleration -framework CoreVideo")
374	endif()
375endif()
376
377list(APPEND THIRD_PARTY_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/blip_buf/blip_buf.c")
378
379if(USE_MAGICK)
380	list(APPEND FEATURES MAGICK)
381	include_directories(AFTER ${MAGICKWAND_INCLUDE_DIRS})
382	link_directories(${MAGICKWAND_LIBRARY_DIRS})
383	list(APPEND FEATURE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/feature/imagemagick/imagemagick-gif-encoder.c")
384	list(APPEND DEPENDENCY_LIB ${MAGICKWAND_LIBRARIES})
385	string(REGEX MATCH "^[0-9]+\\.[0-9]+" MAGICKWAND_VERSION_PARTIAL ${MagickWand_VERSION})
386	if(${MAGICKWAND_VERSION_PARTIAL} EQUAL "6.7")
387		set(MAGICKWAND_DEB_VERSION "5")
388	else()
389		set(MAGICKWAND_DEB_VERSION "-6.q16-2")
390	endif()
391	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libmagickwand${MAGICKWAND_DEB_VERSION}")
392endif()
393
394if(WANT_ZLIB AND NOT USE_ZLIB)
395	set(SKIP_INSTALL_ALL ON)
396	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib zlib)
397	set_property(TARGET zlibstatic PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/zlib;${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib)
398	set_property(TARGET zlib PROPERTY EXCLUDE_FROM_ALL ON)
399	set_property(TARGET example PROPERTY EXCLUDE_FROM_ALL ON)
400	set_property(TARGET minigzip PROPERTY EXCLUDE_FROM_ALL ON)
401	set(ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib)
402	set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib)
403	set(ZLIB_LIBRARY zlibstatic)
404	list(APPEND DEPENDENCY_LIB zlibstatic)
405	set(USE_ZLIB ON)
406endif()
407
408if(USE_ZLIB)
409	list(APPEND FEATURES ZLIB)
410	include_directories(AFTER ${ZLIB_INCLUDE_DIRS})
411	list(APPEND DEPENDENCY_LIB ${ZLIB_LIBRARIES})
412	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},zlib1g")
413endif()
414
415if(WANT_PNG AND USE_ZLIB AND NOT USE_PNG)
416	set(PNG_STATIC ON CACHE BOOL "" FORCE)
417	set(PNG_SHARED OFF CACHE BOOL "" FORCE)
418	set(PNG_TESTS OFF CACHE BOOL "" FORCE)
419	set(SKIP_INSTALL_ALL ON)
420	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng libpng)
421	set_property(TARGET png16_static PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/libpng;${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng;${ZLIB_INCLUDE_DIRS})
422	set(PNG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng ${CMAKE_CURRENT_BINARY_DIR}/libpng)
423	list(APPEND DEPENDENCY_LIB png16_static)
424	set(USE_PNG ON)
425endif()
426
427if(USE_PNG)
428	list(APPEND FEATURES PNG)
429	include_directories(AFTER ${PNG_INCLUDE_DIRS})
430	list(APPEND DEPENDENCY_LIB ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
431	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libpng12-0")
432endif()
433
434if(USE_LIBZIP)
435	include_directories(AFTER ${LIBZIP_INCLUDE_DIRS})
436	link_directories(${LIBZIP_LIBRARY_DIRS})
437	list(APPEND DEPENDENCY_LIB ${LIBZIP_LIBRARIES})
438	list(APPEND FEATURES LIBZIP)
439	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c)
440	string(REGEX MATCH "^[0-9]+" LIBZIP_VERSION_MAJOR ${libzip_VERSION})
441	if (LIBZIP_VERSION_MAJOR LESS 1)
442		set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libzip2")
443	elseif(LIBZIP_VERSION_MAJOR EQUAL 1)
444		set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libzip4")
445	else()
446		message(AUTHOR_WARNING Unknown version of libzip detected: ${libzip_VERSION})
447	endif()
448elseif(USE_MINIZIP)
449	include_directories(AFTER ${MINIZIP_INCLUDE_DIRS})
450	link_directories(${MINIZIP_LIBRARY_DIRS})
451	list(APPEND DEPENDENCY_LIB ${MINIZIP_LIBRARIES})
452	list(APPEND FEATURES MINIZIP)
453	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c)
454	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libminizip1")
455elseif(USE_ZLIB)
456	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c
457		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/ioapi.c
458		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c)
459endif()
460
461if (USE_LZMA)
462	include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/third-party/lzma)
463	add_definitions(-D_7ZIP_PPMD_SUPPPORT)
464	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-lzma.c)
465	set(LZMA_SRC
466		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zAlloc.c
467		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zArcIn.c
468		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zBuf.c
469		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zBuf2.c
470		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zCrc.c
471		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zCrcOpt.c
472		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zDec.c
473		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/CpuArch.c
474		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Delta.c
475		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/LzmaDec.c
476		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Lzma2Dec.c
477		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Bra.c
478		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Bra86.c
479		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/BraIA64.c
480		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Bcj2.c
481		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Ppmd7.c
482		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Ppmd7Dec.c
483		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zFile.c
484		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zStream.c)
485	list(APPEND VFS_SRC ${LZMA_SRC})
486	list(APPEND FEATURES LZMA)
487endif()
488
489if(USE_EPOXY)
490	add_definitions(-DBUILD_GL -DBUILD_GLES2)
491	list(APPEND FEATURES EPOXY)
492	include_directories(AFTER ${EPOXY_INCLUDE_DIRS})
493	set(OPENGLES2_LIBRARY ${EPOXY_LIBRARIES})
494	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libepoxy0")
495endif()
496
497
498set(FEATURE_DEFINES)
499foreach(FEATURE IN LISTS FEATURES)
500	list(APPEND FEATURE_DEFINES "USE_${FEATURE}")
501endforeach()
502
503set(CORE_SRC)
504if(M_CORE_GB)
505	add_definitions(-DM_CORE_GB)
506	list(APPEND CORE_SRC
507		${LR35902_SRC}
508		${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/debugger/debugger.c
509		${GB_SRC}
510		${GB_RENDERER_SRC})
511endif()
512
513if(M_CORE_GBA)
514	add_definitions(-DM_CORE_GBA)
515	list(APPEND CORE_SRC 
516		${ARM_SRC}
517		${CMAKE_CURRENT_SOURCE_DIR}/src/arm/debugger/debugger.c
518		${CMAKE_CURRENT_SOURCE_DIR}/src/arm/debugger/memory-debugger.c
519		${GBA_SRC}
520		${GBA_CHEATS_SRC}
521		${GBA_RENDERER_SRC})
522	if(NOT M_CORE_GB)
523		list(APPEND CORE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/audio.c)
524	endif()
525endif()
526
527source_group("Virtual files" FILES ${CORE_VFS_SRC} ${VFS_SRC})
528source_group("Extra features" FILES ${FEATURE_SRC})
529source_group("Third-party code" FILES ${THIRD_PARTY_SRC})
530
531# Platform binaries
532if(3DS)
533	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/3ds ${CMAKE_CURRENT_BINARY_DIR}/3ds)
534endif()
535
536if(WII)
537	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/wii ${CMAKE_CURRENT_BINARY_DIR}/wii)
538endif()
539
540if(PSP2)
541	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/psp2 ${CMAKE_CURRENT_BINARY_DIR}/psp2)
542endif()
543
544# Binaries
545list(APPEND CORE_SRC
546	${UTIL_SRC}
547	${CORE_VFS_SRC}
548	${DEBUGGER_SRC}
549	${OS_SRC}
550	${THIRD_PARTY_SRC})
551
552set(SRC ${CORE_SRC} ${VFS_SRC})
553if(NOT MINIMAL_CORE)
554	if(M_CORE_GBA)
555		list(APPEND SRC
556			${GBA_RR_SRC}
557			${GBA_EXTRA_SRC}
558			${SIO_SRC})
559	endif()
560	list(APPEND SRC
561		${FEATURE_SRC}
562		${CLI_SRC})
563endif()
564
565if(NOT SKIP_LIBRARY)
566	if(NOT BUILD_STATIC AND NOT BUILD_SHARED)
567		set(BUILD_SHARED ON)
568	endif()
569
570	if(BUILD_SHARED)
571		add_library(${BINARY_NAME} SHARED ${SRC} ${VFS_SRC})
572		if(BUILD_STATIC)
573			add_library(${BINARY_NAME}-static STATIC ${SRC})
574			set_target_properties(${BINARY_NAME}-static PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
575			install(TARGETS ${BINARY_NAME}-static DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME})
576			add_dependencies(${BINARY_NAME}-static version-info)
577		endif()
578	else()
579		add_library(${BINARY_NAME} STATIC ${SRC})
580	endif()
581
582	add_dependencies(${BINARY_NAME} version-info)
583	set_target_properties(${BINARY_NAME} PROPERTIES VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_ABI} COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
584
585	target_link_libraries(${BINARY_NAME} ${DEBUGGER_LIB} ${DEPENDENCY_LIB} ${OS_LIB})
586	install(TARGETS ${BINARY_NAME} LIBRARY DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME} NAMELINK_SKIP ARCHIVE DESTINATION ${LIBDIR} RUNTIME DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME})
587	if(UNIX AND NOT APPLE)
588		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-16.png DESTINATION share/icons/hicolor/16x16/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
589		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-24.png DESTINATION share/icons/hicolor/24x24/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
590		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-32.png DESTINATION share/icons/hicolor/32x32/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
591		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-48.png DESTINATION share/icons/hicolor/48x48/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
592		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-64.png DESTINATION share/icons/hicolor/64x64/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
593		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-96.png DESTINATION share/icons/hicolor/96x96/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
594		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-128.png DESTINATION share/icons/hicolor/128x128/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
595		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-256.png DESTINATION share/icons/hicolor/256x256/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
596		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-512.png DESTINATION share/icons/hicolor/512x512/apps RENAME mgba.png COMPONENT lib${BINARY_NAME})
597	endif()
598else()
599	set(BUILD_SHARED OFF)
600	set(BUILD_STATIC OFF)
601	find_library(${BINARY_NAME} ${BINARY_NAME})
602	if(NOT ${BINARY_NAME}_FOUND)
603		set(DISABLE_FRONTENDS ON)
604		set(BUILD_PERF OFF)
605		set(BUILD_TEST OFF)
606	endif()
607endif()
608
609if(BUILD_GL)
610	add_definitions(-DBUILD_GL)
611endif()
612
613if(BUILD_GLES2)
614	add_definitions(-DBUILD_GLES2)
615endif()
616
617if(DISABLE_FRONTENDS)
618	set(BUILD_SDL OFF)
619	set(BUILD_QT OFF)
620endif()
621
622if(BUILD_LIBRETRO)
623	file(GLOB RETRO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/libretro/*.c)
624	add_library(${BINARY_NAME}_libretro SHARED ${CORE_SRC} ${RETRO_SRC})
625	set_target_properties(${BINARY_NAME}_libretro PROPERTIES PREFIX "" COMPILE_DEFINITIONS "COLOR_16_BIT;COLOR_5_6_5;DISABLE_THREADING;${OS_DEFINES};${FUNCTION_DEFINES};MINIMAL_CORE=2")
626	target_link_libraries(${BINARY_NAME}_libretro ${OS_LIB})
627	install(TARGETS ${BINARY_NAME}_libretro LIBRARY DESTINATION ${LIBDIR} COMPONENT ${BINARY_NAME}_libretro NAMELINK_SKIP)
628endif()
629
630if(BUILD_OPENEMU)
631	find_library(FOUNDATION Foundation)
632	find_library(OPENEMUBASE OpenEmuBase)
633	file(GLOB OE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/openemu/*.m)
634	add_library(${BINARY_NAME}-openemu MODULE ${CORE_SRC} ${OE_SRC})
635	set_target_properties(${BINARY_NAME}-openemu PROPERTIES
636		MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/openemu/Info.plist.in
637		BUNDLE TRUE
638		BUNDLE_EXTENSION oecoreplugin
639		OUTPUT_NAME ${PROJECT_NAME}
640		COMPILE_DEFINITIONS "DISABLE_THREADING;${OS_DEFINES};${FUNCTION_DEFINES};MINIMAL_CORE=1")
641	target_link_libraries(${BINARY_NAME}-openemu ${OS_LIB} ${FOUNDATION} ${OPENEMUBASE})
642	install(TARGETS ${BINARY_NAME}-openemu LIBRARY DESTINATION ${LIBDIR} COMPONENT ${BINARY_NAME}.oecoreplugin NAMELINK_SKIP)
643endif()
644
645if(BUILD_SDL)
646	add_definitions(-DBUILD_SDL)
647	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/sdl ${CMAKE_CURRENT_BINARY_DIR}/sdl)
648endif()
649
650if(BUILD_QT)
651	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/qt ${CMAKE_CURRENT_BINARY_DIR}/qt)
652endif()
653
654if(BUILD_PERF)
655	set(PERF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/test/perf-main.c ${CLI_SRC})
656	if(UNIX AND NOT APPLE)
657		list(APPEND PERF_LIB rt)
658	endif()
659
660	add_executable(${BINARY_NAME}-perf ${PERF_SRC})
661	target_link_libraries(${BINARY_NAME}-perf ${BINARY_NAME} ${PERF_LIB} ${OS_LIB})
662	set_target_properties(${BINARY_NAME}-perf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
663	install(TARGETS ${BINARY_NAME}-perf DESTINATION bin COMPONENT ${BINARY_NAME}-perf)
664	install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/perf.py DESTINATION "${CMAKE_INSTALL_LIBDIR}/${BINARY_NAME}" COMPONENT ${BINARY_NAME}-perf)
665endif()
666
667if(BUILD_TEST)
668	add_executable(${BINARY_NAME}-fuzz ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/test/fuzz-main.c)
669	target_link_libraries(${BINARY_NAME}-fuzz ${BINARY_NAME})
670	set_target_properties(${BINARY_NAME}-fuzz PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
671	install(TARGETS ${BINARY_NAME}-fuzz DESTINATION bin COMPONENT ${BINARY_NAME}-test)
672endif()
673
674if(BUILD_EXAMPLE)
675	add_executable(${BINARY_NAME}-example-server ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/example/client-server/server.c)
676	target_link_libraries(${BINARY_NAME}-example-server ${BINARY_NAME})
677	set_target_properties(${BINARY_NAME}-example-server PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
678
679	if(BUILD_SDL)
680		add_executable(${BINARY_NAME}-example-client ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/example/client-server/client.c)
681		target_link_libraries(${BINARY_NAME}-example-client ${BINARY_NAME} ${SDL_LIBRARY} ${SDLMAIN_LIBRARY} ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY})
682		set_target_properties(${BINARY_NAME}-example-client PROPERTIES
683		                      COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}"
684		                      INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/src")
685	endif()
686endif()
687
688# Packaging
689set(CPACK_PACKAGE_VERSION ${VERSION_STRING})
690set(CPACK_PACKAGE_VERSION_MAJOR ${LIB_VERSION_MAJOR})
691set(CPACK_PACKAGE_VERSION_MINOR ${LIB_VERSION_MINOR})
692set(CPACK_PACKAGE_VERSION_PATCH ${LIB_VERSION_PATCH})
693set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
694set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
695
696set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "mGBA Game Boy Advance Emulator")
697set(CPACK_PACKAGE_VENDOR "Jeffrey Pfau")
698set(CPACK_PACKAGE_CONTACT "Jeffrey Pfau <jeffrey@endrift.com>")
699set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
700set(CPACK_DEBIAN_PACKAGE_SECTION "games")
701
702SET(CPACK_DEB_COMPONENT_INSTALL ON)
703
704set(CPACK_STRIP_FILES ${BINARY_NAME})
705
706install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/CHANGES DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT lib${BINARY_NAME})
707
708include(CPack)
709
710# Summaries
711set(SUMMARY_GL_LIST)
712if(USE_EPOXY)
713	set(SUMMARY_GL_LIST "libepoxy")
714else()
715	if(BUILD_GL)
716		list(APPEND SUMMARY_GL_LIST "OpenGL")
717	endif()
718	if(BUILD_GLES2)
719		list(APPEND SUMMARY_GL_LIST "OpenGL|ES 2")
720	endif()
721endif()
722if(NOT SUMMARY_GL_LIST)
723	set(SUMMARY_GL OFF)
724else()
725	string(REPLACE ";" ", " SUMMARY_GL "${SUMMARY_GL_LIST}")
726endif()
727if(USE_LIBZIP)
728	set(SUMMARY_ZIP libzip)
729elseif(USE_MINIZIP)
730	set(SUMMARY_ZIP "minizip (external)")
731elseif(USE_ZLIB)
732	set(SUMMARY_ZIP "minizip (included)")
733else()
734	set(SUMMARY_ZIP OFF)
735endif()
736
737if(NOT QUIET)
738	message(STATUS "Platforms:")
739	message(STATUS "	Game Boy Advance: ${M_CORE_GBA}")
740	message(STATUS "	Game Boy: ${M_CORE_GB}")
741	message(STATUS "Features:")
742	message(STATUS "	CLI debugger: ${USE_CLI_DEBUGGER}")
743	message(STATUS "	GDB stub: ${USE_GDB_STUB}")
744	message(STATUS "	Video recording: ${USE_FFMPEG}")
745	message(STATUS "	GIF recording: ${USE_MAGICK}")
746	message(STATUS "	Screenshot/advanced savestate support: ${USE_PNG}")
747	message(STATUS "	ZIP support: ${SUMMARY_ZIP}")
748	message(STATUS "	7-Zip support: ${USE_LZMA}")
749	message(STATUS "	OpenGL support: ${SUMMARY_GL}")
750	message(STATUS "Frontends:")
751	message(STATUS "	Qt: ${BUILD_QT}")
752	message(STATUS "	SDL (${SDL_VERSION}): ${BUILD_SDL}")
753	message(STATUS "	Profiling: ${BUILD_PERF}")
754	message(STATUS "	Test harness: ${BUILD_TEST}")
755	message(STATUS "	Examples: ${BUILD_EXAMPLE}")
756	message(STATUS "Cores:")
757	message(STATUS "	Libretro core: ${BUILD_LIBRETRO}")
758	if(APPLE)
759		message(STATUS "	OpenEmu core: ${BUILD_OPENEMU}")
760	endif()
761	message(STATUS "Libraries:")
762	message(STATUS "	Static: ${BUILD_STATIC}")
763	message(STATUS "	Shared: ${BUILD_SHARED}")
764endif()