source: CMakeModules/FindAPR.cmake

Last change on this file was 10700, checked in by Michael Tänzer, 12 years ago

Merge CMake branch into trunk

File size: 5.3 KB
Line 
1# - Find apr
2# Find the Apache Portable Runtime Library headers and libraries.
3#
4# respects the BUILD_STATIC_BINS variable => searches for static library and its
5# dependencies
6#
7# APR_INCLUDE_DIRS - where to find apr.h etc.
8# APRUTIL_INCLUDE_DIRS - where to find apu.h etc.
9# APR_LIBRARIES - List of libraries when using apr.
10# APRUTIL_LIBRARIES - List of libraries when using aprutil.
11# APR_FOUND - True if apr found.
12# APRUTIL_FOUND - True if aprutil found.
13
14
15# [License]
16# The Ariba-Underlay Copyright
17#
18# Copyright (c) 2008-2012, Institute of Telematics, UniversitÀt Karlsruhe (TH)
19#
20# Institute of Telematics
21# UniversitÀt Karlsruhe (TH)
22# Zirkel 2, 76128 Karlsruhe
23# Germany
24#
25# Redistribution and use in source and binary forms, with or without
26# modification, are permitted provided that the following conditions are
27# met:
28#
29# 1. Redistributions of source code must retain the above copyright
30# notice, this list of conditions and the following disclaimer.
31# 2. Redistributions in binary form must reproduce the above copyright
32# notice, this list of conditions and the following disclaimer in the
33# documentation and/or other materials provided with the distribution.
34#
35# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
36# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
39# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
41# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
42# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46#
47# The views and conclusions contained in the software and documentation
48# are those of the authors and should not be interpreted as representing
49# official policies, either expressed or implied, of the Institute of
50# Telematics.
51# [License]
52
53find_package(PkgConfig)
54pkg_check_modules(PC_APR1 QUIET apr-1)
55pkg_check_modules(PC_APRUTIL1 QUIET apr-util-1)
56
57
58# Build static binaries?
59if(BUILD_STATIC_BINS)
60 set(STATIC_ "STATIC_")
61endif(BUILD_STATIC_BINS)
62
63set(APR_DEFINITIONS ${PC_APR1_${STATIC_}CFLAGS_OTHER})
64set(APRUTIL_DEFINITIONS ${PC_APRUTIL1_${STATIC_}CFLAGS_OTHER})
65
66
67# Look for the apr header files.
68find_path(APR_INCLUDE_DIR NAMES apr.h
69 HINTS
70 ${PC_APR1_${STATIC_}INCLUDEDIR}
71 ${PC_APR1_${STATIC_}INCLUDE_DIRS})
72mark_as_advanced(APR_INCLUDE_DIR)
73set(handle_standard_args_variables APR_INCLUDE_DIR)
74
75# Look for the aprutil header files.
76find_path(APRUTIL_INCLUDE_DIR NAMES apu.h
77 HINTS
78 ${PC_APRUTIL1_${STATIC_}INCLUDEDIR}
79 ${PC_APRUTIL1_${STATIC_}INCLUDE_DIRS})
80mark_as_advanced(APRUTIL_INCLUDE_DIR)
81set(util_handle_standard_args_variables APRUTIL_INCLUDE_DIR)
82
83
84# Look for the libraries
85if(NOT PC_APR1_${STATIC_}LIBRARIES)
86 set(PC_APR1_${STATIC_}LIBRARIES apr-1)
87endif()
88
89foreach(LIBRARY ${PC_APR1_${STATIC_}LIBRARIES})
90 find_library(APR_${STATIC_}LIBRARY_${LIBRARY} NAMES ${LIBRARY}
91 DOC "The path to the ${LIBRARY} library used by apr"
92 HINTS
93 ${PC_APR1_${STATIC_}LIBDIR}
94 ${PC_APR1_LIBRARY_${STATIC_}DIRS}
95 )
96 mark_as_advanced(APR_${STATIC_}LIBRARY_${LIBRARY})
97 list(APPEND handle_standard_args_variables
98 "APR_${STATIC_}LIBRARY_${LIBRARY}"
99 )
100endforeach()
101
102foreach(LIBRARY ${PC_APRUTIL1_${STATIC_}LIBRARIES})
103 find_library(APRUTIL_${STATIC_}LIBRARY_${LIBRARY} NAMES ${LIBRARY}
104 DOC "The path to the ${LIBRARY} library used by aprutil"
105 HINTS
106 ${PC_APRUTIL1_${STATIC_}LIBDIR}
107 ${PC_APRUTIL1_LIBRARY_${STATIC_}DIRS}
108 )
109 mark_as_advanced(APRUTIL_${STATIC_}LIBRARY_${LIBRARY})
110 list(APPEND util_handle_standard_args_variables
111 "APRUTIL_${STATIC_}LIBRARY_${LIBRARY}"
112 )
113endforeach()
114
115# handle the QUIETLY and REQUIRED arguments and set LOG4CXX_FOUND to TRUE
116# if all listed variables are TRUE
117find_package(PackageHandleStandardArgs)
118find_package_handle_standard_args(APR DEFAULT_MSG
119 ${handle_standard_args_variables}
120 )
121
122if(APR_FOUND)
123 foreach(LIBRARY ${PC_APR1_${STATIC_}LIBRARIES})
124 list(APPEND APR_LIBRARIES ${APR_${STATIC_}LIBRARY_${LIBRARY}})
125 endforeach()
126
127 # handle APRUTIL
128 foreach(pred ${util_handle_standard_args_variables})
129 if(NOT ${pred})
130 set(APRUTIL_FOUND FALSE)
131 endif()
132 endforeach()
133
134 if(NOT DEFINED APRUTIL_FOUND)
135 set(APRUTIL_FOUND TRUE)
136 endif(NOT DEFINED APRUTIL_FOUND)
137
138 if(APRUTIL_FOUND)
139 find_package(PackageMessage)
140
141 foreach(LIBRARY ${PC_APRUTIL1_${STATIC_}LIBRARIES})
142 set(APRUTIL_${STATIC_}LIBRARY_${LIBRARY}_FIND_QUIETLY ${APR_FIND_QUIETLY})
143 find_package_message(APRUTIL_${STATIC_}LIBRARY_${LIBRARY}
144 "Found ${LIBRARY}: ${APRUTIL_${STATIC_}LIBRARY_${LIBRARY}}"
145 "[${APRUTIL_${STATIC_}LIBRARY_${LIBRARY}}]")
146 list(APPEND APRUTIL_LIBRARIES ${APRUTIL_${STATIC_}LIBRARY_${LIBRARY}})
147 endforeach()
148 endif()
149endif()
Note: See TracBrowser for help on using the repository browser.