From 6f31fca58f019ebfd83a8232c6805cc8b3c05bd7 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 2 May 2019 19:15:49 -0700 Subject: [PATCH] CMake: Improved library-style building --- CMakeLists.txt | 107 +++++++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66c2a4a30..283598a91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,48 +18,67 @@ if(NOT MSVC) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146") endif() -set(USE_DEBUGGERS ON CACHE BOOL "Whether or not to enable the debugging infrastructure") -if (NOT WIN32) - set(USE_EDITLINE ON CACHE BOOL "Whether or not to enable the CLI-mode debugger") + +if(NOT DEFINED LIBMGBA_ONLY) + get_directory_property(LIBMGBA_ONLY EXCLUDE_FROM_ALL) endif() -set(USE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger") -set(USE_FFMPEG ON CACHE BOOL "Whether or not to enable FFmpeg support") -set(USE_ZLIB ON CACHE BOOL "Whether or not to enable zlib support") -set(USE_MINIZIP ON CACHE BOOL "Whether or not to enable external minizip support") -set(USE_PNG ON CACHE BOOL "Whether or not to enable PNG support") -set(USE_LIBZIP ON CACHE BOOL "Whether or not to enable LIBZIP support") -set(USE_MAGICK ON CACHE BOOL "Whether or not to enable ImageMagick support") -set(USE_SQLITE3 ON CACHE BOOL "Whether or not to enable SQLite3 support") -set(USE_ELF ON CACHE BOOL "Whether or not to enable ELF support") -set(M_CORE_GBA ON CACHE BOOL "Build Game Boy Advance core") -set(M_CORE_GB ON CACHE BOOL "Build Game Boy core") -set(USE_LZMA ON CACHE BOOL "Whether or not to enable 7-Zip support") -set(USE_DISCORD_RPC ON CACHE BOOL "Whether or not to enable Discord RPC support") -set(ENABLE_SCRIPTING ON CACHE BOOL "Whether or not to enable scripting support") -set(BUILD_QT ON CACHE BOOL "Build Qt frontend") -set(BUILD_SDL ON CACHE BOOL "Build SDL frontend") -set(BUILD_LIBRETRO OFF CACHE BOOL "Build libretro core") -if(APPLE) - set(BUILD_OPENEMU OFF CACHE BOOL "Build OpenEmu core") -endif() -set(BUILD_PERF OFF CACHE BOOL "Build performance profiling tool") -set(BUILD_TEST OFF CACHE BOOL "Build testing harness") -set(BUILD_SUITE OFF CACHE BOOL "Build test suite") -set(BUILD_EXAMPLE OFF CACHE BOOL "Build example frontends") -set(BUILD_PYTHON OFF CACHE BOOL "Build Python bindings") -set(BUILD_STATIC OFF CACHE BOOL "Build a static library") -set(BUILD_SHARED ON CACHE BOOL "Build a shared library") -set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)") -set(BUILD_GL ON CACHE BOOL "Build with OpenGL") -set(BUILD_GLES2 OFF CACHE BOOL "Build with OpenGL|ES 2") -set(BUILD_GLES3 OFF CACHE BOOL "Build with OpenGL|ES 3") -set(USE_EPOXY ON CACHE STRING "Build with libepoxy") -set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies") -set(DISTBUILD OFF CACHE BOOL "Build distribution packages") -if(WIN32) - set(WIN32_UNIX_PATHS OFF CACHE BOOL "Use Unix-like paths") - mark_as_advanced(WIN32_UNIX_PATHS) + +if(NOT LIBMGBA_ONLY) + set(USE_DEBUGGERS ON CACHE BOOL "Whether or not to enable the debugging infrastructure") + if (NOT WIN32) + set(USE_EDITLINE ON CACHE BOOL "Whether or not to enable the CLI-mode debugger") + endif() + set(USE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger") + set(USE_FFMPEG ON CACHE BOOL "Whether or not to enable FFmpeg support") + set(USE_ZLIB ON CACHE BOOL "Whether or not to enable zlib support") + set(USE_MINIZIP ON CACHE BOOL "Whether or not to enable external minizip support") + set(USE_PNG ON CACHE BOOL "Whether or not to enable PNG support") + set(USE_LIBZIP ON CACHE BOOL "Whether or not to enable LIBZIP support") + set(USE_MAGICK ON CACHE BOOL "Whether or not to enable ImageMagick support") + set(USE_SQLITE3 ON CACHE BOOL "Whether or not to enable SQLite3 support") + set(USE_ELF ON CACHE BOOL "Whether or not to enable ELF support") + set(M_CORE_GBA ON CACHE BOOL "Build Game Boy Advance core") + set(M_CORE_GB ON CACHE BOOL "Build Game Boy core") + set(USE_LZMA ON CACHE BOOL "Whether or not to enable 7-Zip support") + set(USE_DISCORD_RPC ON CACHE BOOL "Whether or not to enable Discord RPC support") + set(ENABLE_SCRIPTING ON CACHE BOOL "Whether or not to enable scripting support") + set(BUILD_QT ON CACHE BOOL "Build Qt frontend") + set(BUILD_SDL ON CACHE BOOL "Build SDL frontend") + set(BUILD_LIBRETRO OFF CACHE BOOL "Build libretro core") + if(APPLE) + set(BUILD_OPENEMU OFF CACHE BOOL "Build OpenEmu core") + endif() + set(BUILD_PERF OFF CACHE BOOL "Build performance profiling tool") + set(BUILD_TEST OFF CACHE BOOL "Build testing harness") + set(BUILD_SUITE OFF CACHE BOOL "Build test suite") + set(BUILD_EXAMPLE OFF CACHE BOOL "Build example frontends") + set(BUILD_PYTHON OFF CACHE BOOL "Build Python bindings") + set(BUILD_STATIC OFF CACHE BOOL "Build a static library") + set(BUILD_SHARED ON CACHE BOOL "Build a shared library") + set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)") + set(BUILD_GL ON CACHE BOOL "Build with OpenGL") + set(BUILD_GLES2 OFF CACHE BOOL "Build with OpenGL|ES 2") + set(BUILD_GLES3 OFF CACHE BOOL "Build with OpenGL|ES 3") + set(USE_EPOXY ON CACHE STRING "Build with libepoxy") + set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies") + set(DISTBUILD OFF CACHE BOOL "Build distribution packages") + if(WIN32) + set(WIN32_UNIX_PATHS OFF CACHE BOOL "Use Unix-like paths") + mark_as_advanced(WIN32_UNIX_PATHS) + endif() +else() + set(DISABLE_FRONTENDS ON) + set(DISABLE_DEPS ON) + set(BUILD_STATIC ON) + set(BUILD_SHARED OFF) + if(NOT DEFINED M_CORE_GBA) + set(M_CORE_GBA ON) + endif() + if(NOT DEFINED M_CORE_GB) + set(M_CORE_GB ON) + endif() endif() + file(GLOB ARM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/arm/*.c) file(GLOB ARM_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/arm/test/*.c) file(GLOB LR35902_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/lr35902/*.c) @@ -91,7 +110,7 @@ source_group("GBA board" FILES ${GBA_SRC} ${GBA_RENDERER_SRC} ${GBA_SIO_SRC}) source_group("GBA extra" FILES ${GBA_CHEATS_SRC} ${GBA_RR_SRC}) source_group("GB board" FILES ${GB_SRC} ${GB_SIO_SRC}) source_group("Utilities" FILES ${UTIL_SRC}) -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src) +include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (e.g. Release, RelWithDebInfo, or Debug)" FORCE) @@ -341,7 +360,9 @@ endif() check_include_files("xlocale.h" HAVE_XLOCALE) if(NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") check_function_exists(snprintf_l HAVE_SNPRINTF_L) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + if(ANDROID AND ANDROID_NDK_MAJOR GREATER_EQUAL 14) + set(HAVE_STRTOF_L ON) + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") # The strtof_l on Linux not actually exposed nor actually strtof_l set(HAVE_STRTOF_L OFF) else() @@ -1247,7 +1268,7 @@ else() set(SUMMARY_ZIP OFF) endif() -if(NOT QUIET) +if(NOT QUIET AND NOT LIBMGBA_ONLY) message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") message(STATUS "Platforms:") message(STATUS " Game Boy Advance: ${M_CORE_GBA}")