all repos — mgba @ 6882339f625b97f344c6464915c2038bc453ea3c

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