1 # Look for JSONCPP if asked to.
2 # We use a bundled version by default because some distros ship versions of
3 # JSONCPP that cause segfaults and other memory errors when we link with them.
4 # See https://github.com/minetest/minetest/issues/1793
6 mark_as_advanced(JSON_LIBRARY JSON_INCLUDE_DIR)
7 option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JSONCPP. May cause segfaults and other memory errors!" FALSE)
9 if(ENABLE_SYSTEM_JSONCPP)
10 find_library(JSON_LIBRARY NAMES jsoncpp)
11 find_path(JSON_INCLUDE_DIR json/allocator.h PATH_SUFFIXES jsoncpp)
13 include(FindPackageHandleStandardArgs)
14 find_package_handle_standard_args(Json DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)
17 message(STATUS "Using system JSONCPP library.")
22 message(STATUS "Using bundled JSONCPP library.")
23 set(JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jsoncpp)
24 set(JSON_LIBRARY jsoncpp)
25 add_subdirectory(lib/jsoncpp)