all repos — mgba @ 1f20b3e430850c14811a8fdf4a91d2f38af6debe

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