FindJson.cmake 963 B

1234567891011121314151617181920212223242526
  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
  5. mark_as_advanced(JSON_LIBRARY JSON_INCLUDE_DIR)
  6. option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JSONCPP. May cause segfaults and other memory errors!" FALSE)
  7. if(ENABLE_SYSTEM_JSONCPP)
  8. find_library(JSON_LIBRARY NAMES jsoncpp)
  9. find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp)
  10. include(FindPackageHandleStandardArgs)
  11. find_package_handle_standard_args(JSONCPP DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)
  12. if(JSONCPP_FOUND)
  13. message(STATUS "Using system JSONCPP library.")
  14. endif()
  15. endif()
  16. if(NOT JSONCPP_FOUND)
  17. message(STATUS "Using bundled JSONCPP library.")
  18. set(JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jsoncpp)
  19. set(JSON_LIBRARY jsoncpp)
  20. add_subdirectory(lib/jsoncpp)
  21. endif()