mirror of
https://github.com/minetest/minetest.git
synced 2024-11-04 14:53:45 +01:00
4503b5097f
* Move included json code to jsoncpp subdirectory This is needed to avoid having to specify the minetest src directory as a system include when fixing the json includes. * Fix json includes They used "", so that the compiler searches the project's directory first. The result was that when compiling with a system jsoncpp, the project's own version of json.h was still included, instead of the system version. The includes now use <>, so a system location, or one specified with '-Ilocation' is searched only. * Fix for jsoncpp deprecated function warning When compiling with a newer version of jsoncpp (and ENABLE_SYSTEM_JSONCPP=true), jsoncpp emits a warning about a deprecated function that minetest uses.
28 lines
955 B
CMake
28 lines
955 B
CMake
# Look for JSONCPP if asked to.
|
|
# We use a bundled version by default because some distros ship versions of
|
|
# JSONCPP that cause segfaults and other memory errors when we link with them.
|
|
# See https://github.com/minetest/minetest/issues/1793
|
|
|
|
mark_as_advanced(JSON_LIBRARY JSON_INCLUDE_DIR)
|
|
option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JSONCPP. May cause segfaults and other memory errors!" FALSE)
|
|
|
|
if(ENABLE_SYSTEM_JSONCPP)
|
|
find_library(JSON_LIBRARY NAMES jsoncpp)
|
|
find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp)
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(JSONCPP DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)
|
|
|
|
if(JSONCPP_FOUND)
|
|
message(STATUS "Using system JSONCPP library.")
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT JSONCPP_FOUND)
|
|
message(STATUS "Using bundled JSONCPP library.")
|
|
set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/jsoncpp)
|
|
set(JSON_LIBRARY jsoncpp)
|
|
add_subdirectory(jsoncpp/json)
|
|
endif()
|
|
|