summaryrefslogtreecommitdiffstats
path: root/cmake/Modules/FindAPR.cmake
blob: c61faa6912a752c0326aeaffccda916129363360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# - Try to find APR
# Once done this will define
#
#  APR_FOUND - system has APR
#  APR_INCLUDE_DIRS - the APR include directory
#  APR_LIBRARIES - Link these to use APR
#  APR_DEFINITIONS - Compiler switches required for using APR
#
#  Copyright (c) 2010 Andreas Schneider <asn@redhat.com>
#
#  Redistribution and use is allowed according to the terms of the New
#  BSD license.
#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#


if (APR_LIBRARIES AND APR_INCLUDE_DIRS)
  # in cache already
  set(APR_FOUND TRUE)
else (APR_LIBRARIES AND APR_INCLUDE_DIRS)
  find_package(PkgConfig)
  if (PKG_CONFIG_FOUND)
    pkg_check_modules(_APR apr-1)
  endif (PKG_CONFIG_FOUND)

  find_path(APR_INCLUDE_DIR
    NAMES
      apr.h
    PATHS
      ${_APR_INCLUDEDIR}
      /usr/include
      /usr/local/include
      /opt/local/include
      /sw/include
    PATH_SUFFIXES
      apr-1
  )

  find_library(APR-1_LIBRARY
    NAMES
      apr-1
    PATHS
      ${_APR_LIBDIR}
      /usr/lib
      /usr/local/lib
      /opt/local/lib
      /sw/lib
  )

  set(APR_INCLUDE_DIRS
    ${APR_INCLUDE_DIR}
  )

  if (APR-1_LIBRARY)
    set(APR_LIBRARIES
        ${APR_LIBRARIES}
        ${APR-1_LIBRARY}
    )
  endif (APR-1_LIBRARY)

  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(APR DEFAULT_MSG APR_LIBRARIES APR_INCLUDE_DIRS)

  # show the APR_INCLUDE_DIRS and APR_LIBRARIES variables only in the advanced view
  mark_as_advanced(APR_INCLUDE_DIRS APR_LIBRARIES)

endif (APR_LIBRARIES AND APR_INCLUDE_DIRS)