freeminer/cmake/Modules/FindJson.cmake

35 lines
1.3 KiB
CMake
Raw Normal View History

# 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-22 02:00:44 +04: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-22 02:00:44 +04:00
if(ENABLE_SYSTEM_JSONCPP)
find_library(JSON_LIBRARY NAMES jsoncpp)
find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp)
2013-02-22 02:00:44 +04: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)
2015-06-17 22:26:13 +03:00
option(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF)
option(JSONCPP_WITH_TESTS OFF)
option(JSONCPP_WITH_POST_BUILD_UNITTEST OFF)
2016-03-24 13:15:32 +03:00
option(JSONCPP_WITH_WARNING_AS_ERROR OFF)
2016-09-22 16:25:25 +03:00
add_subdirectory(external/jsoncpp)
2015-06-17 21:38:23 +03:00
message(STATUS "Using bundled JSONCPP library. ${jsoncpp_BINARY_DIR}")
2016-09-22 16:25:25 +03:00
set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/external/jsoncpp/include)
2020-11-07 18:29:43 +03:00
set(JSON_LIBRARY jsoncpp_static)
2016-09-22 16:25:25 +03:00
#set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/external/jsoncpp)
2016-08-10 19:26:12 +03:00
#set(JSON_LIBRARY jsoncpp)
#add_subdirectory(jsoncpp/json)
endif()
2013-02-22 02:00:44 +04:00