Findjson_rpc_cpp.cmake 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # Find json-rcp-cpp
  2. #
  3. # Find the json-rpc-cpp 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. # JSON_RCP_CPP_INCLUDE_DIRS, where to find header, etc.
  9. # JSON_RCP_CPP_LIBRARIES, the libraries needed to use json-rpc-cpp.
  10. # JSON_RPC_CPP_SERVER_LIBRARIES, the libraries needed to use json-rpc-cpp-server
  11. # JSON_RPC_CPP_CLIENT_LIBRARIES, the libraries needed to use json-rpc-cpp-client
  12. # JSON_RCP_CPP_FOUND, If false, do not try to use json-rpc-cpp.
  13. # JSON_RPC_CPP_VERSION, version of library
  14. # JSON_RPC_CPP_VERSION_MAJOR
  15. # JSON_RPC_CPP_VERSION_MINOR
  16. # JSON_RPC_CPP_VERSION_PATCH
  17. # only look in default directories
  18. find_path(
  19. JSON_RPC_CPP_INCLUDE_DIR
  20. NAMES jsonrpccpp/server.h jsonrpc/server.h
  21. PATH_SUFFIXES jsonrpc
  22. DOC "json-rpc-cpp include dir"
  23. )
  24. find_library(
  25. JSON_RPC_CPP_COMMON_LIBRARY
  26. NAMES jsonrpccpp-common
  27. DOC "json-rpc-cpp common library"
  28. )
  29. find_library(
  30. JSON_RPC_CPP_SERVER_LIBRARY
  31. NAMES jsonrpccpp-server
  32. DOC "json-rpc-cpp server library"
  33. )
  34. find_library(
  35. JSON_RPC_CPP_CLIENT_LIBRARY
  36. NAMES jsonrpccpp-client
  37. DOC "json-rpc-cpp client library"
  38. )
  39. # these are the variables to be uses by the calling script
  40. set (JSON_RPC_CPP_INCLUDE_DIRS ${JSON_RPC_CPP_INCLUDE_DIR})
  41. set (JSON_RPC_CPP_LIBRARIES ${JSON_RPC_CPP_COMMON_LIBRARY} ${JSON_RPC_CPP_SERVER_LIBRARY} ${JSON_RPC_CPP_CLIENT_LIBRARY})
  42. set (JSON_RPC_CPP_SERVER_LIBRARIES ${JSON_RPC_CPP_COMMON_LIBRARY} ${JSON_RPC_CPP_SERVER_LIBRARY})
  43. set (JSON_RPC_CPP_CLIENT_LIBRARIES ${JSON_RPC_CPP_COMMON_LIBRARY} ${JSON_RPC_CPP_CLIENT_LIBRARY})
  44. # debug library on windows
  45. # same naming convention as in qt (appending debug library with d)
  46. # boost is using the same "hack" as us with "optimized" and "debug"
  47. if (JSON_RPC_CPP_INCLUDE_DIR)
  48. set (JSON_RPC_CPP_VERSION_HEADER "${JSON_RPC_CPP_INCLUDE_DIR}/jsonrpccpp/version.h")
  49. if (EXISTS ${JSON_RPC_CPP_VERSION_HEADER})
  50. file (STRINGS ${JSON_RPC_CPP_VERSION_HEADER} JSON_RPC_CPP_VERSION_MAJOR REGEX "^#define JSONRPC_CPP_MAJOR_VERSION[ \t]+[0-9]+$")
  51. file (STRINGS ${JSON_RPC_CPP_VERSION_HEADER} JSON_RPC_CPP_VERSION_MINOR REGEX "^#define JSONRPC_CPP_MINOR_VERSION[ \t]+[0-9]+$")
  52. file (STRINGS ${JSON_RPC_CPP_VERSION_HEADER} JSON_RPC_CPP_VERSION_PATCH REGEX "^#define JSONRPC_CPP_PATCH_VERSION[ \t]+[0-9]+$")
  53. string (REGEX REPLACE "^#define JSONRPC_CPP_MAJOR_VERSION[ \t]+([0-9]+)" "\\1" JSON_RPC_CPP_VERSION_MAJOR ${JSON_RPC_CPP_VERSION_MAJOR})
  54. string (REGEX REPLACE "^#define JSONRPC_CPP_MINOR_VERSION[ \t]+([0-9]+)" "\\1" JSON_RPC_CPP_VERSION_MINOR ${JSON_RPC_CPP_VERSION_MINOR})
  55. string (REGEX REPLACE "^#define JSONRPC_CPP_PATCH_VERSION[ \t]+([0-9]+)" "\\1" JSON_RPC_CPP_VERSION_PATCH ${JSON_RPC_CPP_VERSION_PATCH})
  56. set (JSON_RPC_CPP_VERSION ${JSON_RPC_CPP_VERSION_MAJOR}.${JSON_RPC_CPP_VERSION_MINOR}.${JSON_RPC_CPP_VERSION_PATCH})
  57. endif()
  58. endif()
  59. # handle the QUIETLY and REQUIRED arguments and set JSON_RPC_CPP_FOUND to TRUE
  60. # if all listed variables are TRUE, hide their existence from configuration view
  61. include(FindPackageHandleStandardArgs)
  62. find_package_handle_standard_args(
  63. json_rpc_cpp
  64. REQUIRED_VARS JSON_RPC_CPP_INCLUDE_DIR JSON_RPC_CPP_COMMON_LIBRARY JSON_RPC_CPP_SERVER_LIBRARY JSON_RPC_CPP_CLIENT_LIBRARY
  65. VERSION_VAR JSON_RPC_CPP_VERSION
  66. )
  67. mark_as_advanced (JSON_RPC_CPP_INCLUDE_DIR JSON_RPC_CPP_COMMON_LIBRARY JSON_RPC_CPP_SERVER_LIBRARY JSON_RPC_CPP_CLIENT_LIBRARY)
  68. message( "JSON_RCP_CPP_INCLUDE_DIRS:" ${JSON_RCP_CPP_INCLUDE_DIRS})
  69. message( "JSON_RCP_CPP_LIBRARIES:" ${JSON_RCP_CPP_LIBRARIES})
  70. message( "JSON_RPC_CPP_SERVER_LIBRARIES:" ${JSON_RPC_CPP_SERVER_LIBRARIES})
  71. message( "JSON_RPC_CPP_CLIENT_LIBRARIES:" ${JSON_RPC_CPP_CLIENT_LIBRARIES})
  72. message( "JSON_RCP_CPP_FOUND:" ${JSON_RCP_CPP_FOUND})
  73. message( "JSON_RPC_CPP_VERSION:" ${JSON_RPC_CPP_VERSION})
  74. message( "JSON_RPC_CPP_VERSION_MAJOR:" ${JSON_RPC_CPP_VERSION_MAJOR})
  75. message( "JSON_RPC_CPP_VERSION_MINOR:" ${JSON_RPC_CPP_VERSION_MINOR})
  76. message( "JSON_RPC_CPP_VERSION_PATCH:" ${JSON_RPC_CPP_VERSION_PATCH})