2015-02-28 00:05:29 +01:00
|
|
|
# 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
|
2013-02-21 23:00:44 +01:00
|
|
|
|
2015-02-28 00:05:29 +01:00
|
|
|
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)
|
2013-02-21 23:00:44 +01:00
|
|
|
|
2015-02-28 00:05:29 +01:00
|
|
|
if(ENABLE_SYSTEM_JSONCPP)
|
|
|
|
find_library(JSON_LIBRARY NAMES jsoncpp)
|
2015-08-24 18:05:41 +02:00
|
|
|
find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp)
|
2013-02-21 23:00:44 +01:00
|
|
|
|
2015-02-28 00:05:29 +01:00
|
|
|
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.")
|
2016-08-10 12:10:00 +02:00
|
|
|
set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/jsoncpp)
|
2015-02-28 00:05:29 +01:00
|
|
|
set(JSON_LIBRARY jsoncpp)
|
2016-08-10 12:10:00 +02:00
|
|
|
add_subdirectory(jsoncpp/json)
|
2015-02-28 00:05:29 +01:00
|
|
|
endif()
|
2013-02-21 23:00:44 +01:00
|
|
|
|