+# ``Ldap::Ldap``
+# The LDAP library
+#
+#=============================================================================
+# Copyright 2006 Szombathelyi György <gyurco@freemail.hu>
+# Copyright 2007-2016 Laurent Montel <montel@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+if (NOT APPLE)
+ find_path(Ldap_INCLUDE_DIRS NAMES ldap.h)
+ find_library(Ldap_LIBRARY NAMES ldap)
+ find_library(Lber_LIBRARY NAMES lber)
+else()
+ # OSX ships with an LDAP.framework which seems to be completely broken.
+ # Force using the working version in /usr instead.
+ find_path(Ldap_INCLUDE_DIRS NAMES ldap.h PATHS /usr/include NO_CMAKE_SYSTEM_PATH)
+ find_library(Ldap_LIBRARY NAMES ldap PATHS /usr/lib NO_CMAKE_SYSTEM_PATH)
+ find_library(Lber_LIBRARY NAMES lber PATHS /usr/lib NO_CMAKE_SYSTEM_PATH)
+endif()
+
+set(Ldap_LIBRARIES ${Ldap_LIBRARY})
+if (Ldap_LIBRARY AND Lber_LIBRARY)
+ list(APPEND Ldap_LIBRARIES ${Lber_LIBRARY})
+endif()