FindJsoncpp.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Find jsoncpp
  2. #
  3. # Find the jsoncpp includes and library
  4. #
  5. # if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
  6. #
  7. # This module defines
  8. # JSONCPP_INCLUDE_DIRS, where to find header, etc.
  9. # JSONCPP_LIBRARIES, the libraries needed to use jsoncpp.
  10. # JSONCPP_FOUND, If false, do not try to use jsoncpp.
  11. # JSONCPP_INCLUDE_PREFIX, include prefix for jsoncpp
  12. # only look in default directories
  13. find_path(
  14. JSONCPP_INCLUDE_DIR
  15. NAMES jsoncpp/json/json.h json/json.h
  16. DOC "jsoncpp include dir"
  17. )
  18. find_library(
  19. JSONCPP_LIBRARY
  20. NAMES jsoncpp
  21. DOC "jsoncpp library"
  22. )
  23. set(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR})
  24. set(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
  25. # debug library on windows
  26. # same naming convention as in qt (appending debug library with d)
  27. # boost is using the same "hack" as us with "optimized" and "debug"
  28. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  29. find_library(
  30. JSONCPP_LIBRARY_DEBUG
  31. NAMES jsoncppd
  32. DOC "jsoncpp debug library"
  33. )
  34. set(JSONCPP_LIBRARIES optimized ${JSONCPP_LIBRARIES} debug ${JSONCPP_LIBRARY_DEBUG})
  35. endif()
  36. # find JSONCPP_INCLUDE_PREFIX
  37. find_path(
  38. JSONCPP_INCLUDE_PREFIX
  39. NAMES json.h
  40. PATH_SUFFIXES jsoncpp/json json
  41. )
  42. if (${JSONCPP_INCLUDE_PREFIX} MATCHES "jsoncpp")
  43. set(JSONCPP_INCLUDE_PREFIX "jsoncpp")
  44. set(JSONCPP_INCLUDE_DIRS "${JSONCPP_INCLUDE_DIRS}/jsoncpp")
  45. else()
  46. set(JSONCPP_INCLUDE_PREFIX "")
  47. endif()
  48. # handle the QUIETLY and REQUIRED arguments and set JSONCPP_FOUND to TRUE
  49. # if all listed variables are TRUE, hide their existence from configuration view
  50. include(FindPackageHandleStandardArgs)
  51. find_package_handle_standard_args(jsoncpp DEFAULT_MSG
  52. JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)
  53. mark_as_advanced (JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)