FindJsoncpp.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/json")
  44. else()
  45. set(JSONCPP_INCLUDE_PREFIX "json")
  46. endif()
  47. # handle the QUIETLY and REQUIRED arguments and set JSONCPP_FOUND to TRUE
  48. # if all listed variables are TRUE, hide their existence from configuration view
  49. include(FindPackageHandleStandardArgs)
  50. find_package_handle_standard_args(jsoncpp DEFAULT_MSG
  51. JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)
  52. mark_as_advanced (JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)