CMake: Add json-c optional dependency

This commit is contained in:
Vicki Pfau 2023-01-29 21:56:02 -08:00
parent 00a34e0d07
commit c1e1843e5e
2 changed files with 26 additions and 0 deletions

View File

@ -55,6 +55,7 @@ if(NOT LIBMGBA_ONLY)
set(USE_SQLITE3 ON CACHE BOOL "Whether or not to enable SQLite3 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(USE_ELF ON CACHE BOOL "Whether or not to enable ELF support")
set(USE_LUA ON CACHE BOOL "Whether or not to enable Lua scripting support") set(USE_LUA ON CACHE BOOL "Whether or not to enable Lua scripting support")
set(USE_JSON_C ON CACHE BOOL "Whether or not to enable JSON-C support")
set(M_CORE_GBA ON CACHE BOOL "Build Game Boy Advance core") set(M_CORE_GBA ON CACHE BOOL "Build Game Boy Advance core")
set(M_CORE_GB ON CACHE BOOL "Build Game Boy 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_LZMA ON CACHE BOOL "Whether or not to enable 7-Zip support")
@ -477,6 +478,7 @@ endif()
if(DISABLE_DEPS) if(DISABLE_DEPS)
set(USE_GDB_STUB OFF) set(USE_GDB_STUB OFF)
set(USE_DISCORD_RPC OFF) set(USE_DISCORD_RPC OFF)
set(USE_JSON_C OFF)
set(USE_SQLITE3 OFF) set(USE_SQLITE3 OFF)
set(USE_PNG OFF) set(USE_PNG OFF)
set(USE_ZLIB OFF) set(USE_ZLIB OFF)
@ -765,11 +767,30 @@ endif()
if(ENABLE_SCRIPTING) if(ENABLE_SCRIPTING)
list(APPEND ENABLES SCRIPTING) list(APPEND ENABLES SCRIPTING)
find_feature(USE_JSON_C "json-c")
if(NOT USE_LUA VERSION_LESS 5.1) if(NOT USE_LUA VERSION_LESS 5.1)
find_feature(USE_LUA "Lua" ${USE_LUA}) find_feature(USE_LUA "Lua" ${USE_LUA})
else() else()
find_feature(USE_LUA "Lua") find_feature(USE_LUA "Lua")
endif() endif()
if(USE_JSON_C)
list(APPEND FEATURES JSON_C)
if(TARGET json-c::json-c)
list(APPEND DEPENDENCY_LIB json-c::json-c)
get_target_property(JSON_C_SONAME json-c::json-c IMPORTED_SONAME_NONE)
string(SUBSTRING "${JSON_C_SONAME}" 13 -1 JSON_C_SOVER)
else()
if(${json-c_VERSION} VERSION_LESS 0.13.0)
set(JSON_C_SOVER 3)
elseif(${json-c_VERSION} VERSION_LESS 0.15.0)
set(JSON_C_SOVER 4)
endif()
list(APPEND DEPENDENCY_LIB ${json-c_LIBRARIES})
include_directories(AFTER ${json-c_INCLUDE_DIRS})
link_directories(${json-c_LIBDIRS})
endif()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libjson-c${JSON_C_SOVER}")
endif()
if(USE_LUA) if(USE_LUA)
list(APPEND FEATURE_DEFINES USE_LUA) list(APPEND FEATURE_DEFINES USE_LUA)
include_directories(AFTER ${LUA_INCLUDE_DIR}) include_directories(AFTER ${LUA_INCLUDE_DIR})
@ -1289,6 +1310,7 @@ if(NOT QUIET AND NOT LIBMGBA_ONLY)
else() else()
message(STATUS " Lua: ${USE_LUA}") message(STATUS " Lua: ${USE_LUA}")
endif() endif()
message(STATUS " storage API: ${USE_JSON_C}")
endif() endif()
message(STATUS "Frontends:") message(STATUS "Frontends:")
message(STATUS " Qt: ${BUILD_QT}") message(STATUS " Qt: ${BUILD_QT}")

View File

@ -79,6 +79,10 @@
#cmakedefine USE_GDB_STUB #cmakedefine USE_GDB_STUB
#endif #endif
#ifndef USE_JSON_C
#cmakedefine USE_JSON_C
#endif
#ifndef USE_LIBAV #ifndef USE_LIBAV
#cmakedefine USE_LIBAV #cmakedefine USE_LIBAV
#endif #endif