source: CMakeModules/FindLog4Cxx.cmake

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

Merge CMake branch into trunk

File size: 3.8 KB
Line 
1# - Find Log4Cxx
2# Find the log4cxx logging library
3#
4# respects the BUILD_STATIC_BINS variable => searches for static library and its
5# dependencies
6#
7# LOG4CXX_INCLUDE_DIR - where to find logger.h etc.
8# LOG4CXX_LIBRARIES - List of libraries when using log4cxx.
9# LOG4CXX_FOUND - True if log4cxx was found.
10
11
12# [License]
13# The Ariba-Underlay Copyright
14#
15# Copyright (c) 2008-2012, Institute of Telematics, UniversitÀt Karlsruhe (TH)
16#
17# Institute of Telematics
18# UniversitÀt Karlsruhe (TH)
19# Zirkel 2, 76128 Karlsruhe
20# Germany
21#
22# Redistribution and use in source and binary forms, with or without
23# modification, are permitted provided that the following conditions are
24# met:
25#
26# 1. Redistributions of source code must retain the above copyright
27# notice, this list of conditions and the following disclaimer.
28# 2. Redistributions in binary form must reproduce the above copyright
29# notice, this list of conditions and the following disclaimer in the
30# documentation and/or other materials provided with the distribution.
31#
32# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
33# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
36# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43#
44# The views and conclusions contained in the software and documentation
45# are those of the authors and should not be interpreted as representing
46# official policies, either expressed or implied, of the Institute of
47# Telematics.
48# [License]
49
50find_package(PkgConfig)
51pkg_check_modules(PC_LOG4CXX QUIET liblog4cxx)
52
53# Build static binaries?
54if(BUILD_STATIC_BINS)
55 set(STATIC_ "STATIC_")
56endif(BUILD_STATIC_BINS)
57
58set(LOG4CXX_DEFINITIONS ${PC_LOG4CXX_${STATIC_}CFLAGS_OTHER})
59
60
61# Look for the header files.
62find_path(LOG4CXX_INCLUDE_DIR NAMES log4cxx/logger.h
63 HINTS
64 ${PC_LOG4CXX_${STATIC_}INCLUDEDIR}
65 ${PC_LOG4CXX_${STATIC_}INCLUDE_DIRS})
66mark_as_advanced(LOG4CXX_INCLUDE_DIR)
67set(handle_standard_args_variables LOG4CXX_INCLUDE_DIR)
68
69
70# Look for the libraries
71if(NOT PC_LOG4CXX_${STATIC_}LIBRARIES)
72 set(PC_LOG4CXX_${STATIC_}LIBRARIES log4cxx)
73endif()
74
75foreach(LIBRARY ${PC_LOG4CXX_${STATIC_}LIBRARIES})
76 find_library(LOG4CXX_${STATIC_}LIBRARY_${LIBRARY} NAMES ${LIBRARY}
77 DOC "The path to the ${LIBRARY} library used by log4cxx"
78 HINTS
79 ${PC_LOG4CXX_${STATIC_}LIBDIR}
80 ${PC_LOG4CXX_LIBRARY_${STATIC_}DIRS}
81 )
82 mark_as_advanced(LOG4CXX_${STATIC_}LIBRARY_${LIBRARY})
83 list(APPEND handle_standard_args_variables
84 "LOG4CXX_${STATIC_}LIBRARY_${LIBRARY}"
85 )
86endforeach()
87
88
89# Look for dependency APR
90find_package(APR ${Log4Cxx_FIND_REQUIRED} ${Log4Cxx_FIND_QUIETLY})
91if(NOT APRUTIL_FOUND)
92 message(WARNING "Could not find the Apache Portable Runtime Library which "
93 "is a dependency of Log4Cxx => static linking might fail")
94endif()
95
96
97# handle the QUIETLY and REQUIRED arguments and set LOG4CXX_FOUND to TRUE
98# if all listed variables are TRUE
99find_package(PackageHandleStandardArgs)
100find_package_handle_standard_args(Log4Cxx DEFAULT_MSG
101 ${handle_standard_args_variables}
102 )
103
104if(LOG4CXX_FOUND)
105 foreach(LIBRARY ${PC_LOG4CXX_${STATIC_}LIBRARIES})
106 list(APPEND LOG4CXX_LIBRARIES
107 ${LOG4CXX_${STATIC_}LIBRARY_${LIBRARY}}
108 ${APRUTIL_LIBRARIES}
109 )
110 endforeach()
111endif()
Note: See TracBrowser for help on using the repository browser.