2
0

FindJson.cmake 813 B

12345678910111213141516171819202122232425
  1. # Look for JsonCpp, with fallback to bundeled version
  2. mark_as_advanced(JSON_LIBRARY JSON_INCLUDE_DIR)
  3. option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JsonCpp" TRUE)
  4. set(USE_SYSTEM_JSONCPP FALSE)
  5. if(ENABLE_SYSTEM_JSONCPP)
  6. find_library(JSON_LIBRARY NAMES jsoncpp)
  7. find_path(JSON_INCLUDE_DIR json/allocator.h PATH_SUFFIXES jsoncpp)
  8. if(JSON_LIBRARY AND JSON_INCLUDE_DIR)
  9. message(STATUS "Using JsonCpp provided by system.")
  10. set(USE_SYSTEM_JSONCPP TRUE)
  11. endif()
  12. endif()
  13. if(NOT USE_SYSTEM_JSONCPP)
  14. message(STATUS "Using bundled JsonCpp library.")
  15. set(JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jsoncpp)
  16. set(JSON_LIBRARY jsoncpp)
  17. add_subdirectory(lib/jsoncpp)
  18. endif()
  19. include(FindPackageHandleStandardArgs)
  20. find_package_handle_standard_args(Json DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)