all repos — mgba @ c0a94967ca1295f747d69325787f33bc15f51e76

mGBA Game Boy Advance Emulator

CMakeLists.txt (view raw)

   1cmake_minimum_required(VERSION 3.1)
   2if(POLICY CMP0025)
   3	cmake_policy(SET CMP0025 NEW)
   4endif()
   5project(mGBA)
   6set(BINARY_NAME mgba CACHE INTERNAL "Name of output binaries")
   7if(NOT MSVC)
   8	set(GCC_STD "c99")
   9	if(SWITCH)
  10		set(GCC_STD "gnu11")
  11	elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_COMPILER_VERSION VERSION_LESS "4.3")
  12		set(GCC_STD "gnu99")
  13	endif()
  14	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -std=${GCC_STD}")
  15else()
  16	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146")
  17endif()
  18set(USE_DEBUGGERS ON CACHE BOOL "Whether or not to enable the debugging infrastructure")
  19if (NOT WIN32)
  20	set(USE_EDITLINE ON CACHE BOOL "Whether or not to enable the CLI-mode debugger")
  21endif()
  22set(USE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger")
  23set(USE_FFMPEG ON CACHE BOOL "Whether or not to enable FFmpeg support")
  24set(USE_ZLIB ON CACHE BOOL "Whether or not to enable zlib support")
  25set(USE_MINIZIP ON CACHE BOOL "Whether or not to enable external minizip support")
  26set(USE_PNG ON CACHE BOOL "Whether or not to enable PNG support")
  27set(USE_LIBZIP ON CACHE BOOL "Whether or not to enable LIBZIP support")
  28set(USE_MAGICK ON CACHE BOOL "Whether or not to enable ImageMagick support")
  29set(USE_SQLITE3 ON CACHE BOOL "Whether or not to enable SQLite3 support")
  30set(USE_ELF ON CACHE BOOL "Whether or not to enable ELF support")
  31set(M_CORE_GBA ON CACHE BOOL "Build Game Boy Advance core")
  32set(M_CORE_GB ON CACHE BOOL "Build Game Boy core")
  33set(USE_LZMA ON CACHE BOOL "Whether or not to enable 7-Zip support")
  34set(ENABLE_SCRIPTING ON CACHE BOOL "Whether or not to enable scripting support")
  35set(BUILD_QT ON CACHE BOOL "Build Qt frontend")
  36set(BUILD_SDL ON CACHE BOOL "Build SDL frontend")
  37set(BUILD_LIBRETRO OFF CACHE BOOL "Build libretro core")
  38if(APPLE)
  39	set(BUILD_OPENEMU OFF CACHE BOOL "Build OpenEmu core")
  40endif()
  41set(BUILD_PERF OFF CACHE BOOL "Build performance profiling tool")
  42set(BUILD_TEST OFF CACHE BOOL "Build testing harness")
  43set(BUILD_SUITE OFF CACHE BOOL "Build test suite")
  44set(BUILD_EXAMPLE OFF CACHE BOOL "Build example frontends")
  45set(BUILD_PYTHON OFF CACHE BOOL "Build Python bindings")
  46set(BUILD_STATIC OFF CACHE BOOL "Build a static library")
  47set(BUILD_SHARED ON CACHE BOOL "Build a shared library")
  48set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)")
  49set(BUILD_GL ON CACHE STRING "Build with OpenGL")
  50set(BUILD_GLES2 OFF CACHE STRING "Build with OpenGL|ES 2")
  51set(USE_EPOXY ON CACHE STRING "Build with libepoxy")
  52set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies")
  53set(DISTBUILD OFF CACHE BOOL "Build distribution packages")
  54if(WIN32)
  55	set(WIN32_UNIX_PATHS OFF CACHE BOOL "Use Unix-like paths")
  56	mark_as_advanced(WIN32_UNIX_PATHS)
  57endif()
  58file(GLOB ARM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/arm/*.c)
  59file(GLOB ARM_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/arm/test/*.c)
  60file(GLOB LR35902_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/*.c)
  61file(GLOB LR35902_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/test/*.c)
  62file(GLOB GBA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/*.c)
  63file(GLOB GBA_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/test/*.c)
  64file(GLOB GB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/*.c)
  65file(GLOB GB_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/test/*.c)
  66file(GLOB GBA_CHEATS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/cheats/*.c)
  67file(GLOB GBA_RR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/rr/*.c)
  68file(GLOB CORE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/core/*.c)
  69file(GLOB CORE_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/core/test/*.c)
  70file(GLOB UTIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/*.c)
  71file(GLOB UTIL_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/test/*.c)
  72file(GLOB GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/gui/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/feature/gui/*.c)
  73file(GLOB GBA_RENDERER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/renderers/*.c)
  74file(GLOB GBA_SIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/sio/*.c)
  75file(GLOB GBA_EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/extra/*.c)
  76file(GLOB GB_SIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/sio/*.c)
  77file(GLOB GB_RENDERER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/renderers/*.c)
  78file(GLOB GB_EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/extra/*.c)
  79file(GLOB THIRD_PARTY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/inih/*.c)
  80file(GLOB EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/feature/*.c)
  81set(CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-mem.c ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-fifo.c)
  82set(VFS_SRC)
  83source_group("ARM core" FILES ${ARM_SRC})
  84source_group("LR35902 core" FILES ${LR35902_SRC})
  85source_group("GBA board" FILES ${GBA_SRC} ${GBA_RENDERER_SRC} ${GBA_SIO_SRC})
  86source_group("GBA extra" FILES ${GBA_CHEATS_SRC} ${GBA_RR_SRC})
  87source_group("GB board" FILES ${GB_SRC} ${GB_SIO_SRC})
  88source_group("Utilities" FILES ${UTIL_SRC})
  89include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)
  90
  91if(NOT CMAKE_BUILD_TYPE)
  92	set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (e.g. Release or Debug)" FORCE)
  93endif()
  94
  95if(UNIX OR WIN32_UNIX_PATHS)
  96	include(GNUInstallDirs)
  97else()
  98	set(CMAKE_INSTALL_LIBDIR ".")
  99	set(CMAKE_INSTALL_BINDIR ".")
 100	set(CMAKE_INSTALL_DATADIR ".")
 101	set(CMAKE_INSTALL_DOCDIR ".")
 102	set(CMAKE_INSTALL_INCLUDEDIR "include")
 103endif()
 104
 105set(LIBDIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installed library directory")
 106mark_as_advanced(LIBDIR)
 107
 108if (BUILD_LIBRETRO)
 109	set(LIBRETRO_LIBDIR "${LIBDIR}" CACHE PATH "Installed library directory (Libretro)")
 110	mark_as_advanced(LIBRETRO_LIBDIR)
 111endif()
 112
 113if (BUILD_OPENEMU)
 114	set(OE_LIBDIR "${LIBDIR}" CACHE PATH "Installed library directory (OpenEmu)")
 115	mark_as_advanced(OE_LIBDIR)
 116endif()
 117
 118if (DISTBUILD)
 119       set(EXTRA_LICENSES "" CACHE FILEPATH "Extra licenses to include in distribution packaages")
 120       mark_as_advanced(EXTRA_LICENSES)
 121endif()
 122mark_as_advanced(DISTBUILD)
 123
 124set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
 125
 126if (NOT DEFINED MANDIR)
 127	set(MANDIR ${CMAKE_INSTALL_MANDIR})
 128endif()
 129
 130# Function definitions
 131include(FindPkgConfig)
 132function(find_feature FEATURE_NAME FEATURE_REQUIRES)
 133	if (NOT ${FEATURE_NAME})
 134		return()
 135	endif()
 136	if (DISABLE_DEPS)
 137		set(${FEATURE_NAME} OFF PARENT_SCOPE)
 138		return()
 139	endif()
 140	foreach(REQUIRE ${FEATURE_REQUIRES})
 141		if(NOT ${REQUIRE}_FOUND)
 142			find_package(${REQUIRE} QUIET)
 143			if(NOT ${REQUIRE}_FOUND)
 144				pkg_search_module(${REQUIRE} ${REQUIRE})
 145				if (NOT ${REQUIRE}_FOUND)
 146					message(WARNING "Requested module ${REQUIRE} missing for feature ${FEATURE_NAME}. Feature disabled.")
 147					set(${FEATURE_NAME} OFF PARENT_SCOPE)
 148					return()
 149				endif()
 150			endif()
 151		endif()
 152		string(TOUPPER ${REQUIRE} UREQUIRE)
 153		set(${UREQUIRE}_CFLAGS_OTHER ${${REQUIRE}_CFLAGS_OTHER} PARENT_SCOPE)
 154		set(${UREQUIRE}_FOUND ${${REQUIRE}_FOUND} PARENT_SCOPE)
 155		set(${UREQUIRE}_INCLUDE_DIRS ${${REQUIRE}_INCLUDE_DIRS} PARENT_SCOPE)
 156		set(${UREQUIRE}_VERSION_STRING ${${REQUIRE}_VERSION_STRING} PARENT_SCOPE)
 157		if (APPLE)
 158			set(IS_FRAMEWORK OFF)
 159			set(LIBS)
 160			foreach(LIB IN LISTS ${REQUIRE}_LIBRARIES)
 161				if(LIB STREQUAL "-framework")
 162					set(IS_FRAMEWORK ON)
 163				elseif(IS_FRAMEWORK)
 164					list(APPEND LIBS "-framework ${LIB}")
 165					set(IS_FRAMEWORK OFF)
 166				else()
 167					list(APPEND LIBS ${LIB})
 168				endif()
 169			endforeach()
 170			set(${UREQUIRE}_LIBRARIES ${LIBS} PARENT_SCOPE)
 171		else()
 172			set(${UREQUIRE}_LIBRARIES ${${REQUIRE}_LIBRARIES} PARENT_SCOPE)
 173		endif()
 174		set(${UREQUIRE}_LIBRARY_DIRS ${${REQUIRE}_LIBRARY_DIRS} PARENT_SCOPE)
 175		set(${UREQUIRE}_LDFLAGS_OTHER ${${REQUIRE}_LDFLAGS_OTHER} PARENT_SCOPE)
 176	endforeach()
 177endfunction()
 178
 179# Version information
 180add_custom_target(version-info ALL
 181	COMMAND ${CMAKE_COMMAND}
 182	-DBINARY_NAME=${BINARY_NAME}
 183	-DCONFIG_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/core/version.c.in
 184	-DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.c
 185	-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
 186	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 187
 188include(${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
 189configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/core/version.c.in ${CMAKE_CURRENT_BINARY_DIR}/version.c)
 190
 191list(APPEND UTIL_SRC ${CMAKE_CURRENT_BINARY_DIR}/version.c)
 192source_group("Generated sources" FILES ${CMAKE_CURRENT_BINARY_DIR}/version.c)
 193
 194# Advanced settings
 195if(NOT DEFINED 3DS AND NOT (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_COMPILER_VERSION VERSION_LESS "4.5"))
 196	# LTO appears to make 3DS binary slower
 197	set(DEFAULT_LTO ON)
 198else()
 199	set(DEFAULT_LTO OFF)
 200endif()
 201
 202set(BUILD_LTO ${DEFAULT_LTO} CACHE BOOL "Build with link-time optimization")
 203set(BUILD_PGO OFF CACHE BOOL "Build with profiling-guided optimization")
 204set(PGO_STAGE_2 CACHE BOOL "Rebuild for profiling-guided optimization after profiles have been generated")
 205set(PGO_DIR "/tmp/gba-pgo/" CACHE PATH "Profiling-guided optimization profiles path")
 206mark_as_advanced(BUILD_LTO BUILD_PGO PGO_STAGE_2 PGO_DIR)
 207set(PGO_PRE_FLAGS "-fprofile-generate=${PGO_DIR} -fprofile-arcs")
 208set(PGO_POST_FLAGS "-fprofile-use=${PGO_DIR} -fbranch-probabilities")
 209
 210if(BUILD_PGO AND NOT PGO_STAGE_2)
 211	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${PGO_PRE_FLAGS}")
 212	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PGO_PRE_FLAGS}")
 213	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PGO_PRE_FLAGS}")
 214elseif(BUILD_PGO AND PGO_STAGE_2)
 215	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${PGO_POST_FLAGS}")
 216	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PGO_POST_FLAGS}")
 217	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PGO_POST_FLAGS}")
 218endif()
 219
 220# Platform support
 221if(WIN32)
 222	set(WIN32_VERSION "${LIB_VERSION_MAJOR},${LIB_VERSION_MINOR},${LIB_VERSION_PATCH}")
 223	add_definitions(-D_WIN32_WINNT=0x0600)
 224	list(APPEND OS_LIB ws2_32 shlwapi)
 225	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)
 226	file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/windows/*.c)
 227	source_group("Windows-specific code" FILES ${OS_SRC})
 228	if(MSVC)
 229		add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
 230		set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
 231	endif()
 232elseif(UNIX)
 233	set(USE_PTHREADS ON)
 234	add_definitions(-DUSE_PTHREADS)
 235
 236	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 237		add_definitions(-D_GNU_SOURCE)
 238	endif()
 239	if(NOT APPLE AND NOT HAIKU)
 240		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
 241		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
 242	endif()
 243
 244	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)
 245	file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/posix/*.c)
 246	source_group("POSIX-specific code" FILES ${OS_SRC})
 247endif()
 248
 249if(APPLE)
 250	add_definitions(-D_DARWIN_C_SOURCE)
 251	if(CMAKE_SYSTEM_VERSION VERSION_GREATER "10.5.8")
 252		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.6")
 253	endif()
 254endif()
 255
 256if(NOT HAIKU AND NOT MSVC AND NOT PSP2)
 257	set(M_LIBRARY m)
 258endif()
 259list(APPEND OS_LIB ${M_LIBRARY})
 260
 261if(APPLE OR CMAKE_C_COMPILER_ID STREQUAL "GNU" AND BUILD_LTO)
 262	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
 263	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
 264endif()
 265
 266if(BUILD_BBB OR BUILD_RASPI OR BUILD_PANDORA)
 267	if(NOT BUILD_EGL)
 268		add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
 269	endif()
 270endif()
 271
 272if(BUILD_RASPI)
 273	set(BUILD_GL OFF CACHE BOOL "OpenGL not supported" FORCE)
 274endif()
 275
 276if(BUILD_PANDORA)
 277	add_definitions(-DBUILD_PANDORA)
 278endif()
 279
 280if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*")
 281	enable_language(ASM)
 282endif()
 283
 284if(PSP2 OR WII)
 285	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
 286endif()
 287
 288if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII OR DEFINED SWITCH)
 289	set(IS_EMBEDDED ON)
 290	set(USE_DEBUGGERS OFF)
 291	set(USE_SQLITE3 OFF)
 292endif()
 293
 294if(DEFINED 3DS)
 295	add_definitions(-DFIXED_ROM_BUFFER)
 296endif()
 297
 298if(NOT M_CORE_GBA)
 299	set(USE_GDB_STUB OFF)
 300endif()
 301
 302if(NOT USE_DEBUGGERS)
 303	set(USE_EDITLINE OFF)
 304	set(USE_GDB_STUB OFF)
 305endif()
 306
 307if(WII)
 308	add_definitions(-U__STRICT_ANSI__)
 309endif()
 310
 311if(DEFINED 3DS)
 312	add_definitions(-D_GNU_SOURCE)
 313endif()
 314
 315include(CheckFunctionExists)
 316include(CheckIncludeFiles)
 317check_function_exists(strdup HAVE_STRDUP)
 318check_function_exists(strndup HAVE_STRNDUP)
 319if(NOT DEFINED PSP2)
 320	check_function_exists(localtime_r HAVE_LOCALTIME_R)
 321endif()
 322check_include_files("xlocale.h" HAVE_XLOCALE)
 323if(NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
 324	check_function_exists(snprintf_l HAVE_SNPRINTF_L)
 325	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 326		# The strtof_l on Linux not actually exposed nor actually strtof_l
 327		set(HAVE_STRTOF_L OFF)
 328	else()
 329		check_function_exists(strtof_l HAVE_STRTOF_L)
 330	endif()
 331	check_function_exists(newlocale HAVE_NEWLOCALE)
 332	check_function_exists(freelocale HAVE_FREELOCALE)
 333	check_function_exists(uselocale HAVE_USELOCALE)
 334	check_function_exists(setlocale HAVE_SETLOCALE)
 335else()
 336	if(DEFINED 3DS OR DEFINED WII OR DEFINED SWITCH)
 337		set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,snprintf_l)
 338		check_function_exists(snprintf_l HAVE_SNPRINTF_L)
 339		set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,strtof_l)
 340		check_function_exists(strtof_l HAVE_STRTOF_L)
 341		set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,newlocale)
 342		check_function_exists(newlocale HAVE_NEWLOCALE)
 343		set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,freelocale)
 344		check_function_exists(freelocale HAVE_FREELOCALE)
 345		set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,uselocale)
 346		check_function_exists(uselocale HAVE_USELOCALE)
 347		set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,setlocale)
 348		check_function_exists(setlocale HAVE_SETLOCALE)
 349		unset(CMAKE_REQUIRED_FLAGS)
 350	endif()
 351	if(NOT IS_EMBEDDED)
 352		set(DISABLE_DEPS ON CACHE BOOL "This platform cannot build with dependencies" FORCE)
 353	endif()
 354	set(BUILD_STATIC ON CACHE BOOL "" FORCE)
 355	set(BUILD_SHARED OFF CACHE BOOL "" FORCE)
 356	set(DISABLE_FRONTENDS ON)
 357	set(MINIMAL_CORE ON)
 358	set(ENABLE_EXTRA ON)
 359endif()
 360
 361check_function_exists(chmod HAVE_CHMOD)
 362check_function_exists(umask HAVE_UMASK)
 363
 364set(FUNCTION_DEFINES)
 365
 366if(HAVE_STRDUP)
 367	list(APPEND FUNCTION_DEFINES HAVE_STRDUP)
 368endif()
 369
 370if(HAVE_STRNDUP)
 371	list(APPEND FUNCTION_DEFINES HAVE_STRNDUP)
 372endif()
 373
 374if(HAVE_LOCALTIME_R)
 375	list(APPEND FUNCTION_DEFINES HAVE_LOCALTIME_R)
 376endif()
 377
 378if(HAVE_NEWLOCALE AND HAVE_FREELOCALE AND HAVE_USELOCALE OR APPLE)
 379	list(APPEND FUNCTION_DEFINES HAVE_LOCALE)
 380	if (HAVE_SNPRINTF_L)
 381		list(APPEND FUNCTION_DEFINES HAVE_SNPRINTF_L)
 382	endif()
 383endif()
 384
 385if(HAVE_SETLOCALE)
 386	list(APPEND FUNCTION_DEFINES HAVE_SETLOCALE)
 387endif()
 388
 389if (HAVE_STRTOF_L)
 390	list(APPEND FUNCTION_DEFINES HAVE_STRTOF_L)
 391endif()
 392
 393if(HAVE_XLOCALE)
 394	list(APPEND FUNCTION_DEFINES HAVE_XLOCALE)
 395endif()
 396
 397if(HAVE_CHMOD)
 398	list(APPEND FUNCTION_DEFINES HAVE_CHMOD)
 399endif()
 400
 401if(HAVE_UMASK)
 402	list(APPEND FUNCTION_DEFINES HAVE_UMASK)
 403endif()
 404
 405# Feature dependencies
 406set(FEATURE_DEFINES)
 407set(FEATURE_FLAGS)
 408set(FEATURES)
 409set(ENABLES)
 410if(CMAKE_SYSTEM_NAME MATCHES .*BSD)
 411	set(LIBEDIT_LIBRARIES -ledit)
 412	if (CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
 413		list(APPEND LIBEDIT_LIBRARIES -ltermcap)
 414	endif()
 415else()
 416	find_feature(USE_EDITLINE "libedit")
 417endif()
 418if(BUILD_GL)
 419	find_package(OpenGL QUIET)
 420	if(NOT OPENGL_FOUND)
 421		set(BUILD_GL OFF CACHE BOOL "OpenGL not found" FORCE)
 422	endif()
 423endif()
 424if(NOT BUILD_GL)
 425	set(OPENGLE_LIBRARY "" CACHE PATH "" FORCE)
 426endif()
 427if(BUILD_GLES2 AND NOT BUILD_RASPI)
 428	find_path(OPENGLES2_INCLUDE_DIR NAMES GLES2/gl2.h)
 429	find_library(OPENGLES2_LIBRARY NAMES GLESv2 GLESv2_CM)
 430	if(NOT OPENGLES2_INCLUDE_DIR OR NOT OPENGLES2_LIBRARY)
 431		set(BUILD_GLES2 OFF CACHE BOOL "OpenGL|ES 2 not found" FORCE)
 432	endif()
 433endif()
 434if(NOT BUILD_GLES2)
 435	set(OPENGLES2_LIBRARY "" CACHE PATH "" FORCE)
 436endif()
 437set(WANT_ZLIB ${USE_ZLIB})
 438set(WANT_PNG ${USE_PNG})
 439set(WANT_LIBZIP ${USE_LIBZIP})
 440set(WANT_SQLITE3 ${USE_SQLITE3})
 441set(USE_CMOCKA ${BUILD_SUITE})
 442
 443find_feature(USE_FFMPEG "libavcodec;libavformat;libavutil;libswscale")
 444find_feature(USE_ZLIB "ZLIB")
 445find_feature(USE_MINIZIP "minizip")
 446find_feature(USE_PNG "PNG")
 447find_feature(USE_LIBZIP "libzip")
 448find_feature(USE_MAGICK "MagickWand")
 449find_feature(USE_EPOXY "epoxy")
 450find_feature(USE_CMOCKA "cmocka")
 451find_feature(USE_SQLITE3 "sqlite3")
 452find_feature(USE_ELF "libelf")
 453find_feature(ENABLE_PYTHON "PythonLibs")
 454
 455if(USE_FFMPEG)
 456	set(USE_LIBAVRESAMPLE ON)
 457	set(USE_LIBSWRESAMPLE ON)
 458	find_feature(USE_LIBAVRESAMPLE "libavresample")
 459	find_feature(USE_LIBSWRESAMPLE "libswresample")
 460endif()
 461
 462# Features
 463set(DEBUGGER_SRC
 464	${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/debugger.c
 465	${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/parser.c
 466	${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/symbols.c
 467	${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/cli-debugger.c)
 468
 469file(GLOB DEBUGGER_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/test/*.c)
 470
 471set(FEATURE_SRC)
 472set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
 473
 474if(DISABLE_DEPS)
 475	set(USE_GDB_STUB OFF)
 476endif()
 477
 478if(USE_EDITLINE)
 479	list(APPEND FEATURES EDITLINE)
 480	include_directories(AFTER ${LIBEDIT_INCLUDE_DIRS})
 481	link_directories(${LIBEDIT_LIBRARY_DIRS})
 482	set(DEBUGGER_LIB ${LIBEDIT_LIBRARIES})
 483	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libedit2")
 484	list(APPEND FEATURE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/feature/editline/cli-el-backend.c")
 485else()
 486	set(DEBUGGER_LIB "")
 487endif()
 488
 489if(USE_GDB_STUB)
 490	list(APPEND FEATURES GDB_STUB)
 491	list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/debugger/gdb-stub.c)
 492endif()
 493source_group("Debugger" FILES ${DEBUGGER_SRC})
 494
 495if(USE_FFMPEG)
 496	list(APPEND FEATURES FFMPEG)
 497	if(USE_LIBSWRESAMPLE)
 498		list(APPEND FEATURES LIBSWRESAMPLE)
 499	else()
 500		list(APPEND FEATURES LIBAVRESAMPLE)
 501		list(APPEND FEATURES LIBAV)
 502	endif()
 503	include_directories(AFTER ${LIBAVCODEC_INCLUDE_DIRS} ${LIBAVFORMAT_INCLUDE_DIRS} ${LIBAVRESAMPLE_INCLUDE_DIRS} ${LIBAVUTIL_INCLUDE_DIRS} ${LIBSWRESAMPLE_INCLUDE_DIRS} ${LIBSWSCALE_INCLUDE_DIRS})
 504	link_directories(${LIBAVCODEC_LIBRARY_DIRS} ${LIBAVFORMAT_LIBRARY_DIRS} ${LIBAVRESAMPLE_LIBRARY_DIRS} ${LIBAVUTIL_LIBRARY_DIRS} ${LIBSWRESAMPLE_LIBRARY_DIRS} ${LIBSWSCALE_LIBRARY_DIRS})
 505	list(APPEND FEATURE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/feature/ffmpeg/ffmpeg-encoder.c")
 506	string(REGEX MATCH "^[0-9]+" LIBAVCODEC_VERSION_MAJOR ${libavcodec_VERSION})
 507	string(REGEX MATCH "^[0-9]+" LIBAVFORMAT_VERSION_MAJOR ${libavformat_VERSION})
 508	string(REGEX MATCH "^[0-9]+" LIBAVUTIL_VERSION_MAJOR ${libavutil_VERSION})
 509	string(REGEX MATCH "^[0-9]+" LIBSWSCALE_VERSION_MAJOR ${libswscale_VERSION})
 510	list(APPEND DEPENDENCY_LIB ${LIBAVCODEC_LIBRARIES} ${LIBAVFORMAT_LIBRARIES} ${LIBAVRESAMPLE_LIBRARIES} ${LIBAVUTIL_LIBRARIES} ${LIBSWSCALE_LIBRARIES} ${LIBSWRESAMPLE_LIBRARIES})
 511	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}")
 512	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libavformat${LIBAVFORMAT_VERSION_MAJOR}|libavformat-ffmpeg${LIBAVFORMAT_VERSION_MAJOR}")
 513	if(USE_LIBSWRESAMPLE)
 514		string(REGEX MATCH "^[0-9]+" LIBSWRESAMPLE_VERSION_MAJOR ${libswresample_VERSION})
 515		math(EXPR LIBSWRESAMPLE_VERSION_DEBIAN "${LIBSWRESAMPLE_VERSION_MAJOR} - 1")
 516		set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libswresample${LIBSWRESAMPLE_VERSION_DEBIAN}|libswresample-ffmpeg${LIBSWRESAMPLE_VERSION_DEBIAN}")
 517	else()
 518		string(REGEX MATCH "^[0-9]+" LIBAVRESAMPLE_VERSION_MAJOR ${libavresample_VERSION})
 519		set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libavresample${LIBAVRESAMPLE_VERSION_MAJOR}|libavresample-ffmpeg${LIBAVRESAMPLE_VERSION_MAJOR}")
 520	endif()
 521	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libavutil${LIBAVUTIL_VERSION_MAJOR}|libavutil-ffmpeg${LIBAVUTIL_VERSION_MAJOR}")
 522	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libswscale${LIBSWSCALE_VERSION_MAJOR}|libswscale-ffmpeg${LIBSWSCALE_VERSION_MAJOR}")
 523	set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libavcodec-extra|libavcodec-ffmpeg-extra${LIBAVCODEC_VERSION_MAJOR}")
 524	if(APPLE)
 525		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework VideoDecodeAcceleration -framework CoreVideo")
 526		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework VideoDecodeAcceleration -framework CoreVideo")
 527	endif()
 528endif()
 529
 530list(APPEND THIRD_PARTY_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/blip_buf/blip_buf.c")
 531
 532if(USE_MAGICK)
 533	list(APPEND FEATURES MAGICK)
 534	include_directories(AFTER ${MAGICKWAND_INCLUDE_DIRS})
 535	link_directories(${MAGICKWAND_LIBRARY_DIRS})
 536	list(APPEND FEATURE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/feature/imagemagick/imagemagick-gif-encoder.c")
 537	list(APPEND DEPENDENCY_LIB ${MAGICKWAND_LIBRARIES})
 538	string(REGEX MATCH "^[0-9]+\\.[0-9]+" MAGICKWAND_VERSION_PARTIAL ${MagickWand_VERSION})
 539	string(REGEX MATCH "^[0-9]+" MAGICKWAND_VERSION_MAJOR ${MagickWand_VERSION})
 540	if(${MAGICKWAND_VERSION_PARTIAL} EQUAL "6.7")
 541		set(MAGICKWAND_DEB_VERSION "5")
 542	elseif(${MagickWand_VERSION} EQUAL "6.9.7")
 543		set(MAGICKWAND_DEB_VERSION "-6.q16-3")
 544	else()
 545		set(MAGICKWAND_DEB_VERSION "-6.q16-2")
 546	endif()
 547	list(APPEND FEATURE_DEFINES MAGICKWAND_VERSION_MAJOR=${MAGICKWAND_VERSION_MAJOR})
 548	list(APPEND FEATURE_FLAGS ${MAGICKWAND_CFLAGS_OTHER})
 549
 550	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libmagickwand${MAGICKWAND_DEB_VERSION}")
 551endif()
 552
 553if(WANT_ZLIB AND NOT USE_ZLIB)
 554	set(SKIP_INSTALL_ALL ON)
 555	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib zlib)
 556	set_property(TARGET zlibstatic PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/zlib;${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib)
 557	set_property(TARGET zlib PROPERTY EXCLUDE_FROM_ALL ON)
 558	set_property(TARGET example PROPERTY EXCLUDE_FROM_ALL ON)
 559	set_property(TARGET minigzip PROPERTY EXCLUDE_FROM_ALL ON)
 560	set(ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib)
 561	set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib)
 562	set(ZLIB_LIBRARY zlibstatic)
 563	list(APPEND DEPENDENCY_LIB zlibstatic)
 564	set(USE_ZLIB ON)
 565endif()
 566
 567if(USE_ZLIB)
 568	list(APPEND FEATURES ZLIB)
 569	include_directories(AFTER ${ZLIB_INCLUDE_DIRS})
 570	list(APPEND DEPENDENCY_LIB ${ZLIB_LIBRARIES})
 571	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},zlib1g")
 572	set(HAVE_CRC32 ON)
 573	list(APPEND OS_LIB ${ZLIB_LIBRARIES})
 574else()
 575	# zlib pulls in crc32
 576	check_function_exists(crc32 HAVE_CRC32)
 577endif()
 578
 579if(HAVE_CRC32)
 580	list(APPEND FUNCTION_DEFINES HAVE_CRC32)
 581endif()
 582
 583if(WANT_PNG AND USE_ZLIB AND NOT USE_PNG)
 584	set(PNG_STATIC ON CACHE BOOL "" FORCE)
 585	set(PNG_SHARED OFF CACHE BOOL "" FORCE)
 586	set(PNG_TESTS OFF CACHE BOOL "" FORCE)
 587	set(SKIP_INSTALL_ALL ON)
 588	if (SWITCH)
 589		set(PNG_ARM_NEON "off" CACHE STRING "" FORCE)
 590	endif()
 591	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng libpng)
 592	set_property(TARGET png_static PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/libpng;${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng;${ZLIB_INCLUDE_DIRS})
 593	set(PNG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng ${CMAKE_CURRENT_BINARY_DIR}/libpng)
 594	list(APPEND DEPENDENCY_LIB png_static)
 595	set(USE_PNG ON)
 596endif()
 597
 598if(USE_PNG)
 599	list(APPEND FEATURES PNG)
 600	include_directories(AFTER ${PNG_INCLUDE_DIRS})
 601	list(APPEND DEPENDENCY_LIB ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
 602	if(PNG_VERSION_STRING)
 603		string(REGEX MATCH "^[0-9]+\\.[0-9]+" PNG_VERSION_PARTIAL ${PNG_VERSION_STRING})
 604		if(${PNG_VERSION_PARTIAL} STREQUAL "1.6")
 605			set(PNG_DEB_VERSION "16-16")
 606		else()
 607			set(PNG_DEB_VERSION "12-0")
 608		endif()
 609		set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libpng${PNG_DEB_VERSION}")
 610	endif()
 611endif()
 612
 613if(WANT_SQLITE3 AND NOT USE_SQLITE3)
 614	list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/sqlite3/sqlite3.c)
 615	include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/sqlite3/)
 616	set(USE_SQLITE3 ON)
 617endif()
 618
 619if(USE_LIBZIP)
 620	include_directories(AFTER ${LIBZIP_INCLUDE_DIRS})
 621	link_directories(${LIBZIP_LIBRARY_DIRS})
 622	list(APPEND DEPENDENCY_LIB ${LIBZIP_LIBRARIES})
 623	list(APPEND FEATURES LIBZIP)
 624	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c)
 625	string(REGEX MATCH "^[0-9]+" LIBZIP_VERSION_MAJOR ${libzip_VERSION})
 626	if (LIBZIP_VERSION_MAJOR LESS 1)
 627		set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libzip2")
 628	elseif(LIBZIP_VERSION_MAJOR EQUAL 1)
 629		set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libzip4")
 630	else()
 631		message(AUTHOR_WARNING Unknown version of libzip detected: ${libzip_VERSION})
 632	endif()
 633elseif(USE_MINIZIP)
 634	include_directories(AFTER ${MINIZIP_INCLUDE_DIRS})
 635	link_directories(${MINIZIP_LIBRARY_DIRS})
 636	list(APPEND DEPENDENCY_LIB ${MINIZIP_LIBRARIES})
 637	list(APPEND FEATURES MINIZIP)
 638	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c)
 639	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libminizip1")
 640elseif(USE_ZLIB)
 641	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c
 642		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/ioapi.c
 643		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c)
 644	if(NOT MSVC)
 645		set_source_files_properties(
 646			${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/ioapi.c
 647			${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c
 648			PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter -Wno-implicit-function-declaration")
 649	endif()
 650endif()
 651
 652if (USE_LZMA)
 653	include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma)
 654	add_definitions(-D_7ZIP_PPMD_SUPPPORT)
 655	list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-lzma.c)
 656	set(LZMA_SRC
 657		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zAlloc.c
 658		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zArcIn.c
 659		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zBuf.c
 660		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zBuf2.c
 661		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zCrc.c
 662		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zCrcOpt.c
 663		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zDec.c
 664		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/CpuArch.c
 665		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Delta.c
 666		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/LzmaDec.c
 667		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Lzma2Dec.c
 668		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Bra.c
 669		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Bra86.c
 670		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/BraIA64.c
 671		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Bcj2.c
 672		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Ppmd7.c
 673		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/Ppmd7Dec.c
 674		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zFile.c
 675		${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/lzma/7zStream.c)
 676	list(APPEND VFS_SRC ${LZMA_SRC})
 677	list(APPEND FEATURES LZMA)
 678endif()
 679
 680if(USE_EPOXY)
 681	add_definitions(-DBUILD_GL -DBUILD_GLES2)
 682	list(APPEND FEATURES EPOXY)
 683	include_directories(AFTER ${EPOXY_INCLUDE_DIRS})
 684	set(OPENGLES2_LIBRARY ${EPOXY_LIBRARIES})
 685	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libepoxy0")
 686endif()
 687
 688if(USE_SQLITE3)
 689	list(APPEND FEATURES SQLITE3)
 690	include_directories(AFTER ${SQLITE3_INCLUDE_DIRS})
 691	list(APPEND DEPENDENCY_LIB ${SQLITE3_LIBRARIES})
 692	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libsqlite3-0")
 693	list(APPEND FEATURE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/feature/sqlite3/no-intro.c")
 694endif()
 695
 696if(USE_ELF)
 697	list(APPEND FEATURES ELF)
 698	include_directories(AFTER ${LIBELF_INCLUDE_DIRS})
 699	list(APPEND DEPENDENCY_LIB ${LIBELF_LIBRARIES})
 700	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libelf1")
 701endif()
 702
 703if(ENABLE_SCRIPTING)
 704	list(APPEND ENABLES SCRIPTING)
 705
 706	if(BUILD_PYTHON)
 707		find_package(PythonLibs ${USE_PYTHON_VERSION})
 708		list(APPEND DEPENDENCY_LIB ${PYTHON_LIBRARIES})
 709		include_directories(AFTER ${PYTHON_INCLUDE_DIRS})
 710		list(APPEND ENABLES PYTHON)
 711	endif()
 712endif()
 713
 714set(TEST_SRC ${CORE_TEST_SRC})
 715if(M_CORE_GB)
 716	add_definitions(-DM_CORE_GB)
 717	list(APPEND CORE_SRC
 718		${LR35902_SRC}
 719		${GB_SRC}
 720		${GB_RENDERER_SRC})
 721	list(APPEND DEBUGGER_SRC
 722		${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/debugger/cli-debugger.c
 723		${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/debugger/debugger.c
 724		${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/debugger/memory-debugger.c
 725		${CMAKE_CURRENT_SOURCE_DIR}/src/gb/debugger/cli.c
 726		${CMAKE_CURRENT_SOURCE_DIR}/src/gb/debugger/symbols.c)
 727	list(APPEND TEST_SRC
 728		${LR35902_TEST_SRC}
 729		${GB_TEST_SRC})
 730endif()
 731
 732if(M_CORE_GBA)
 733	add_definitions(-DM_CORE_GBA)
 734	list(APPEND CORE_SRC
 735		${ARM_SRC}
 736		${GBA_SRC}
 737		${GBA_CHEATS_SRC}
 738		${GBA_RENDERER_SRC})
 739	list(APPEND DEBUGGER_SRC
 740		${CMAKE_CURRENT_SOURCE_DIR}/src/arm/debugger/cli-debugger.c
 741		${CMAKE_CURRENT_SOURCE_DIR}/src/arm/debugger/debugger.c
 742		${CMAKE_CURRENT_SOURCE_DIR}/src/arm/debugger/memory-debugger.c
 743		${CMAKE_CURRENT_SOURCE_DIR}/src/gba/debugger/cli.c)
 744	list(APPEND TEST_SRC
 745		${ARM_TEST_SRC}
 746		${GBA_TEST_SRC})
 747	if(NOT M_CORE_GB)
 748		list(APPEND CORE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/audio.c)
 749	endif()
 750endif()
 751
 752if(USE_DEBUGGERS)
 753	list(APPEND FEATURE_SRC ${DEBUGGER_SRC})
 754	list(APPEND TEST_SRC ${DEBUGGER_TEST_SRC})
 755	list(APPEND FEATURES DEBUGGERS)
 756endif()
 757
 758foreach(FEATURE IN LISTS FEATURES)
 759	list(APPEND FEATURE_DEFINES "USE_${FEATURE}")
 760endforeach()
 761
 762foreach(ENABLE IN LISTS ENABLES)
 763	list(APPEND FEATURE_DEFINES "ENABLE_${ENABLE}")
 764endforeach()
 765
 766source_group("Virtual files" FILES ${CORE_VFS_SRC} ${VFS_SRC})
 767source_group("Extra features" FILES ${FEATURE_SRC})
 768source_group("Third-party code" FILES ${THIRD_PARTY_SRC})
 769
 770# Platform binaries
 771if(DEFINED 3DS)
 772	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/3ds ${CMAKE_CURRENT_BINARY_DIR}/3ds)
 773endif()
 774
 775if(DEFINED WII)
 776	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/wii ${CMAKE_CURRENT_BINARY_DIR}/wii)
 777endif()
 778
 779if(DEFINED PSP2)
 780	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/psp2 ${CMAKE_CURRENT_BINARY_DIR}/psp2)
 781endif()
 782
 783if(DEFINED SWITCH)
 784	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/switch ${CMAKE_CURRENT_BINARY_DIR}/switch)
 785endif()
 786
 787# Binaries
 788list(APPEND CORE_SRC
 789	${UTIL_SRC}
 790	${CORE_VFS_SRC}
 791	${OS_SRC}
 792	${THIRD_PARTY_SRC})
 793list(APPEND TEST_SRC ${UTIL_TEST_SRC})
 794
 795set(SRC ${CORE_SRC} ${VFS_SRC})
 796if(NOT MINIMAL_CORE)
 797	set(ENABLE_EXTRA ON)
 798	if(M_CORE_GBA)
 799		list(APPEND SRC
 800			${GBA_SIO_SRC})
 801	endif()
 802	if(M_CORE_GB)
 803		list(APPEND SRC
 804			${GB_SIO_SRC})
 805	endif()
 806	list(APPEND SRC
 807		${FEATURE_SRC})
 808endif()
 809
 810if(ENABLE_EXTRA)
 811	if(M_CORE_GBA)
 812		list(APPEND SRC
 813			${GBA_RR_SRC}
 814			${GBA_EXTRA_SRC})
 815	endif()
 816	if(M_CORE_GB)
 817		list(APPEND SRC
 818			${GB_EXTRA_SRC})
 819	endif()
 820	list(APPEND SRC
 821		${EXTRA_SRC})
 822endif()
 823
 824if(NOT SKIP_LIBRARY)
 825	if(NOT BUILD_STATIC AND NOT BUILD_SHARED)
 826		set(BUILD_SHARED ON)
 827	endif()
 828
 829	if(BUILD_SHARED)
 830		add_library(${BINARY_NAME} SHARED ${SRC} ${VFS_SRC})
 831		if(BUILD_STATIC)
 832			add_library(${BINARY_NAME}-static STATIC ${SRC})
 833			set_target_properties(${BINARY_NAME}-static PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}")
 834			install(TARGETS ${BINARY_NAME}-static DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME})
 835			add_dependencies(${BINARY_NAME}-static version-info)
 836		endif()
 837	else()
 838		add_library(${BINARY_NAME} STATIC ${SRC})
 839	endif()
 840
 841	add_dependencies(${BINARY_NAME} version-info)
 842	set_target_properties(${BINARY_NAME} PROPERTIES VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_ABI} COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}")
 843
 844	target_link_libraries(${BINARY_NAME} ${DEBUGGER_LIB} ${DEPENDENCY_LIB} ${OS_LIB})
 845	install(TARGETS ${BINARY_NAME} LIBRARY DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME} NAMELINK_SKIP ARCHIVE DESTINATION ${LIBDIR} RUNTIME DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME})
 846	if(UNIX AND NOT APPLE AND NOT HAIKU)
 847		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-16.png DESTINATION share/icons/hicolor/16x16/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 848		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-24.png DESTINATION share/icons/hicolor/24x24/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 849		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-32.png DESTINATION share/icons/hicolor/32x32/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 850		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-48.png DESTINATION share/icons/hicolor/48x48/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 851		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-64.png DESTINATION share/icons/hicolor/64x64/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 852		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-96.png DESTINATION share/icons/hicolor/96x96/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 853		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-128.png DESTINATION share/icons/hicolor/128x128/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 854		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-256.png DESTINATION share/icons/hicolor/256x256/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 855		install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-512.png DESTINATION share/icons/hicolor/512x512/apps RENAME mgba.png COMPONENT ${BINARY_NAME})
 856	endif()
 857else()
 858	set(BUILD_SHARED OFF)
 859	set(BUILD_STATIC OFF)
 860	find_library(${BINARY_NAME} ${BINARY_NAME})
 861	if(NOT ${BINARY_NAME}_FOUND)
 862		set(DISABLE_FRONTENDS ON)
 863		set(BUILD_PERF OFF)
 864		set(BUILD_TEST OFF)
 865		set(BUILD_SUITE OFF)
 866	endif()
 867endif()
 868
 869if(BUILD_GL)
 870	add_definitions(-DBUILD_GL)
 871endif()
 872
 873if(BUILD_GLES2)
 874	add_definitions(-DBUILD_GLES2)
 875endif()
 876
 877if(DISABLE_FRONTENDS)
 878	set(BUILD_SDL OFF)
 879	set(BUILD_QT OFF)
 880endif()
 881
 882if(BUILD_PYTHON)
 883	enable_testing()
 884	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/python ${CMAKE_CURRENT_BINARY_DIR}/python)
 885endif()
 886
 887if(BUILD_LIBRETRO)
 888	file(GLOB RETRO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/libretro/*.c)
 889	add_library(${BINARY_NAME}_libretro SHARED ${CORE_SRC} ${RETRO_SRC})
 890	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")
 891	target_link_libraries(${BINARY_NAME}_libretro ${OS_LIB})
 892	install(TARGETS ${BINARY_NAME}_libretro LIBRARY DESTINATION ${LIBRETRO_LIBDIR} COMPONENT ${BINARY_NAME}_libretro NAMELINK_SKIP)
 893endif()
 894
 895if(BUILD_OPENEMU)
 896	find_library(FOUNDATION Foundation)
 897	find_library(OPENEMUBASE OpenEmuBase)
 898	file(GLOB OE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/openemu/*.m)
 899	add_library(${BINARY_NAME}-openemu MODULE ${CORE_SRC} ${OS_SRC})
 900	set_target_properties(${BINARY_NAME}-openemu PROPERTIES
 901		MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/openemu/Info.plist.in
 902		BUNDLE TRUE
 903		BUNDLE_EXTENSION oecoreplugin
 904		OUTPUT_NAME ${PROJECT_NAME}
 905		COMPILE_DEFINITIONS "DISABLE_THREADING;${OS_DEFINES};${FUNCTION_DEFINES};MINIMAL_CORE=1")
 906	target_link_libraries(${BINARY_NAME}-openemu ${OS_LIB} ${FOUNDATION} ${OPENEMUBASE})
 907	install(TARGETS ${BINARY_NAME}-openemu LIBRARY DESTINATION ${OE_LIBDIR} COMPONENT ${BINARY_NAME}.oecoreplugin NAMELINK_SKIP)
 908endif()
 909
 910if(BUILD_SDL)
 911	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/sdl ${CMAKE_CURRENT_BINARY_DIR}/sdl)
 912endif()
 913
 914if(BUILD_QT)
 915	add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/qt ${CMAKE_CURRENT_BINARY_DIR}/qt)
 916endif()
 917
 918if(BUILD_PERF)
 919	set(PERF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/test/perf-main.c)
 920	if(UNIX AND NOT APPLE)
 921		list(APPEND PERF_LIB rt)
 922	endif()
 923
 924	add_executable(${BINARY_NAME}-perf ${PERF_SRC})
 925	target_link_libraries(${BINARY_NAME}-perf ${BINARY_NAME} ${PERF_LIB} ${OS_LIB})
 926	set_target_properties(${BINARY_NAME}-perf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
 927	install(TARGETS ${BINARY_NAME}-perf DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${BINARY_NAME}-perf)
 928	install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/perf.py DESTINATION "${LIBDIR}/${BINARY_NAME}" COMPONENT ${BINARY_NAME}-perf)
 929endif()
 930
 931if(BUILD_TEST)
 932	add_executable(${BINARY_NAME}-fuzz ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/test/fuzz-main.c)
 933	target_link_libraries(${BINARY_NAME}-fuzz ${BINARY_NAME})
 934	set_target_properties(${BINARY_NAME}-fuzz PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
 935	add_executable(tbl-fuzz ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/test/tbl-fuzz-main.c)
 936	target_link_libraries(tbl-fuzz ${BINARY_NAME})
 937	set_target_properties(tbl-fuzz PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
 938	install(TARGETS ${BINARY_NAME}-fuzz tbl-fuzz DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${BINARY_NAME}-test)
 939endif()
 940
 941if(NOT USE_CMOCKA)
 942	set(BUILD_SUITE OFF)
 943endif()
 944if(BUILD_SUITE)
 945	enable_testing()
 946	include_directories(AFTER ${CMOCKA_INCLUDE_DIRS})
 947	link_directories(${CMOCKA_LIBRARY_DIRS})
 948
 949	foreach(TEST IN LISTS TEST_SRC)
 950		string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" TEST_NAME "${TEST}")
 951		string(REPLACE "/" "-" TEST_NAME "${TEST_NAME}")
 952		string(REPLACE "-test" "" TEST_NAME "${TEST_NAME}")
 953		string(REPLACE ".c" "" TEST_NAME "${TEST_NAME}")
 954		add_executable(test-${TEST_NAME} ${TEST})
 955		target_link_libraries(test-${TEST_NAME} ${BINARY_NAME} ${PLATFORM_LIBRARY} cmocka)
 956		set_target_properties(test-${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
 957		add_test(${TEST_NAME} test-${TEST_NAME})
 958	endforeach()
 959endif()
 960
 961if(BUILD_EXAMPLE)
 962	add_executable(${BINARY_NAME}-example-server ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/example/client-server/server.c)
 963	target_link_libraries(${BINARY_NAME}-example-server ${BINARY_NAME})
 964	set_target_properties(${BINARY_NAME}-example-server PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
 965
 966	if(SDL_FOUND)
 967		add_executable(${BINARY_NAME}-example-client ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/example/client-server/client.c)
 968		target_link_libraries(${BINARY_NAME}-example-client ${BINARY_NAME} ${SDL_LIBRARY} ${SDLMAIN_LIBRARY} ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY})
 969		set_target_properties(${BINARY_NAME}-example-client PROPERTIES
 970		                      COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}"
 971		                      INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/src;${CMAKE_CURRENT_SOURCE_DIR}/include")
 972	endif()
 973endif()
 974
 975configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/core/flags.h.in ${CMAKE_CURRENT_BINARY_DIR}/flags.h)
 976install(FILES ${CMAKE_CURRENT_BINARY_DIR}/flags.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mgba COMPONENT lib${BINARY_NAME})
 977
 978# Packaging
 979install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/licenses DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME})
 980if(EXTRA_LICENSES)
 981	install(FILES ${EXTRA_LICENSES} DESTINATION ${CMAKE_INSTALL_DOCDIR}/licenses COMPONENT ${BINARY_NAME})
 982endif()
 983
 984file(GLOB READMES ${CMAKE_CURRENT_SOURCE_DIR}/README*.md)
 985
 986find_program(DOS2UNIX NAMES dos2unix)
 987find_program(MARKDOWN NAMES markdown kramdown pandoc)
 988
 989if(UNIX OR NOT DOS2UNIX)
 990	if(UNIX OR NOT MARKDOWN)
 991		install(FILES ${READMES} DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME})
 992	endif()
 993	install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES" "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME})
 994else()
 995	add_custom_command(OUTPUT CHANGES.txt COMMAND ${DOS2UNIX} -n "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES" "${CMAKE_CURRENT_BINARY_DIR}/CHANGES.txt" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES")
 996	add_custom_command(OUTPUT LICENSE.txt COMMAND ${DOS2UNIX} -n "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
 997	add_custom_target(CHANGES ALL DEPENDS CHANGES.txt)
 998	add_custom_target(LICENSE ALL DEPENDS LICENSE.txt)
 999	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CHANGES.txt ${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME})
1000endif()
1001
1002if(MARKDOWN)
1003	foreach(README ${READMES})
1004		get_filename_component(README_BASE "${README}" NAME_WE)
1005		add_custom_command(OUTPUT ${README_BASE}.html COMMAND ${MARKDOWN} "${README}" > ${README_BASE}.html MAIN_DEPENDENCY "${README}")
1006		add_custom_target(${README_BASE} ALL DEPENDS ${README_BASE}.html)
1007		install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${README_BASE}.html DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME})
1008	endforeach()
1009endif()
1010
1011set(CPACK_PACKAGE_VERSION ${VERSION_STRING})
1012set(CPACK_PACKAGE_VERSION_MAJOR ${LIB_VERSION_MAJOR})
1013set(CPACK_PACKAGE_VERSION_MINOR ${LIB_VERSION_MINOR})
1014set(CPACK_PACKAGE_VERSION_PATCH ${LIB_VERSION_PATCH})
1015set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
1016set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
1017
1018set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "mGBA Game Boy Advance Emulator")
1019set(CPACK_PACKAGE_VENDOR "Jeffrey Pfau")
1020set(CPACK_PACKAGE_CONTACT "Jeffrey Pfau <jeffrey@endrift.com>")
1021set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
1022set(CPACK_DEBIAN_PACKAGE_SECTION "games")
1023
1024SET(CPACK_DEB_COMPONENT_INSTALL ON)
1025
1026set(CPACK_STRIP_FILES ON)
1027
1028if(DISTBUILD)
1029	set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
1030	if(WIN32 OR APPLE)
1031		set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-qt ${BINARY_NAME}-sdl ${BINARY_NAME}-perf)
1032		set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
1033	elseif(3DS)
1034		set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-3ds ${BINARY_NAME}-perf)
1035	elseif(WII)
1036		set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-wii)
1037	elseif(PSP2)
1038		set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-psp2)
1039	endif()
1040endif()
1041
1042include(CPack)
1043
1044cpack_add_component_group(base)
1045cpack_add_component(${BINARY_NAME} GROUP base)
1046
1047cpack_add_component_group(dev PARENT_GROUP base)
1048if(BUILD_SHARED)
1049	cpack_add_component(lib${BINARY_NAME} GROUP base)
1050	if(BUILD_STATIC)
1051		cpack_add_component(lib${BINARY_NAME}-static GROUP dev)
1052	endif()
1053elseif(BUILD_STATIC)
1054	cpack_add_component(lib${BINARY_NAME} GROUP dev)
1055endif()
1056
1057if(3DS)
1058	cpack_add_component(${BINARY_NAME}-3ds GROUP base)
1059elseif(PSP2)
1060	cpack_add_component(${BINARY_NAME}-psp2 GROUP base)
1061elseif(WII)
1062	cpack_add_component(${BINARY_NAME}-wii GROUP base)
1063endif()
1064
1065if(BUILD_QT)
1066	cpack_add_component_group(qt PARENT_GROUP base)
1067	cpack_add_component(${BINARY_NAME}-qt GROUP qt)
1068endif()
1069
1070if(SDL_FOUND)
1071	cpack_add_component_group(sdl PARENT_GROUP base)
1072	cpack_add_component(${BINARY_NAME}-sdl GROUP sdl)
1073endif()
1074
1075cpack_add_component_group(test PARENT_GROUP dev)
1076cpack_add_component(${BINARY_NAME}-perf GROUP test)
1077cpack_add_component(${BINARY_NAME}-fuzz GROUP test)
1078cpack_add_component(tbl-fuzz GROUP test)
1079
1080# Summaries
1081set(SUMMARY_GL_LIST)
1082if(USE_EPOXY)
1083	set(SUMMARY_GL_LIST "libepoxy")
1084else()
1085	if(BUILD_GL)
1086		list(APPEND SUMMARY_GL_LIST "OpenGL")
1087	endif()
1088	if(BUILD_GLES2)
1089		list(APPEND SUMMARY_GL_LIST "OpenGL|ES 2")
1090	endif()
1091endif()
1092if(NOT SUMMARY_GL_LIST)
1093	set(SUMMARY_GL OFF)
1094else()
1095	string(REPLACE ";" ", " SUMMARY_GL "${SUMMARY_GL_LIST}")
1096endif()
1097if(USE_LIBZIP)
1098	set(SUMMARY_ZIP libzip)
1099elseif(USE_MINIZIP)
1100	set(SUMMARY_ZIP "minizip (external)")
1101elseif(USE_ZLIB)
1102	set(SUMMARY_ZIP "minizip (included)")
1103else()
1104	set(SUMMARY_ZIP OFF)
1105endif()
1106
1107if(NOT QUIET)
1108	message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
1109	message(STATUS "Platforms:")
1110	message(STATUS "	Game Boy Advance: ${M_CORE_GBA}")
1111	message(STATUS "	Game Boy: ${M_CORE_GB}")
1112	message(STATUS "Features:")
1113	message(STATUS "	Debuggers: ${USE_DEBUGGERS}")
1114	if(NOT WIN32)
1115		message(STATUS "	CLI debugger: ${USE_EDITLINE}")
1116	endif()
1117	message(STATUS "	GDB stub: ${USE_GDB_STUB}")
1118	message(STATUS "	Video recording: ${USE_FFMPEG}")
1119	message(STATUS "	GIF recording: ${USE_MAGICK}")
1120	message(STATUS "	Screenshot/advanced savestate support: ${USE_PNG}")
1121	message(STATUS "	ZIP support: ${SUMMARY_ZIP}")
1122	message(STATUS "	7-Zip support: ${USE_LZMA}")
1123	message(STATUS "	SQLite3 game database: ${USE_SQLITE3}")
1124	message(STATUS "	ELF loading support: ${USE_ELF}")
1125	message(STATUS "	OpenGL support: ${SUMMARY_GL}")
1126	message(STATUS "Frontends:")
1127	message(STATUS "	Qt: ${BUILD_QT}")
1128	message(STATUS "	SDL (${SDL_VERSION}): ${BUILD_SDL}")
1129	message(STATUS "	Profiling: ${BUILD_PERF}")
1130	message(STATUS "	Test harness: ${BUILD_TEST}")
1131	message(STATUS "	Test suite: ${BUILD_SUITE}")
1132	message(STATUS "	Python bindings: ${BUILD_PYTHON}")
1133	message(STATUS "	Examples: ${BUILD_EXAMPLE}")
1134	message(STATUS "Cores:")
1135	message(STATUS "	Libretro core: ${BUILD_LIBRETRO}")
1136	if(APPLE)
1137		message(STATUS "	OpenEmu core: ${BUILD_OPENEMU}")
1138	endif()
1139	message(STATUS "Libraries:")
1140	message(STATUS "	Static: ${BUILD_STATIC}")
1141	message(STATUS "	Shared: ${BUILD_SHARED}")
1142endif()