FindAPR.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # FindAPR
  5. # -------
  6. #
  7. # Find Apache Portable Runtime
  8. #
  9. # This will define the following variables::
  10. #
  11. # APR_FOUND - True if the system has the libraries
  12. # APR_INCLUDE_DIRS - where to find the headers
  13. # APR_LIBRARIES - where to find the libraries
  14. # APR_DEFINITIONS - compile definitions
  15. #
  16. # and the following imported targets::
  17. #
  18. # Apache::Apr - The library
  19. #
  20. # Hints:
  21. # Set ``APR_ROOT_DIR`` to the root directory of an installation.
  22. #
  23. include(FindPackageHandleStandardArgs)
  24. find_package(PkgConfig QUIET)
  25. pkg_check_modules(PC_APR QUIET apr-1)
  26. find_path(APR_INCLUDE_DIR apr.h
  27. HINTS
  28. ${APR_ROOT_DIR}/include
  29. ${APR_ROOT_INCLUDE_DIRS}
  30. PATHS
  31. ${PC_APR_INCLUDE_DIRS}
  32. /usr/local/include
  33. /usr/include
  34. PATH_SUFFIXES
  35. apr-1
  36. apr-1.0
  37. )
  38. find_library(APR_LIBRARY
  39. NAMES apr-1 ${APR_NAMES}
  40. HINTS
  41. ${APR_ROOT_DIR}/lib
  42. ${APR_ROOT_LIBRARY_DIRS}
  43. PATHS
  44. ${PC_APR_LIBRARY_DIRS}
  45. /usr/lib
  46. /usr/local/lib
  47. )
  48. set(APR_VERSION ${PC_APR_VERSION})
  49. find_package_handle_standard_args(APR
  50. FOUND_VAR APR_FOUND
  51. REQUIRED_VARS
  52. APR_INCLUDE_DIR
  53. APR_LIBRARY
  54. VERSION_VAR APR_VERSION
  55. )
  56. if(APR_FOUND)
  57. set(APR_LIBRARIES ${APR_LIBRARY})
  58. set(APR_INCLUDE_DIRS ${APR_INCLUDE_DIR})
  59. set(APR_DEFINITIONS ${PC_APR_CFLAGS_OTHER})
  60. # Deprecated declarations.
  61. SET (NATIVE_APR_INCLUDE_PATH ${APR_INCLUDE_DIR} )
  62. GET_FILENAME_COMPONENT (NATIVE_APR_LIB_PATH ${APR_LIBRARY} PATH)
  63. endif()
  64. if(APR_FOUND AND NOT TARGET Apache::Apr)
  65. add_library(Apache::Apr UNKNOWN IMPORTED)
  66. set_target_properties(Apache::Apr PROPERTIES
  67. IMPORTED_LOCATION "${APR_LIBRARY}"
  68. INTERFACE_COMPILE_OPTIONS "${PC_APR_CFLAGS_OTHER}"
  69. INTERFACE_INCLUDE_DIRECTORIES "${APR_INCLUDE_DIR}"
  70. )
  71. endif()
  72. mark_as_advanced(
  73. APR_LIBRARY
  74. APR_INCLUDE_DIR
  75. )