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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
# Copyright (c) 2019, 2025, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is designed to work with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have either included with
# the program or referenced in the documentation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# cmake -DWITH_LDAP=system|</path/to/custom/installation>
# system is the default
# Custom path is only supported for LINUX_STANDALONE platforms.
INCLUDE (CheckIncludeFile)
INCLUDE (CheckIncludeFiles)
SET(WITH_LDAP_DOC "\nsystem (use the OS ldap library)")
STRING_APPEND(WITH_LDAP_DOC ", \n</path/to/custom/installation>")
STRING(REPLACE "\n" "| " WITH_LDAP_DOC_STRING "${WITH_LDAP_DOC}")
FUNCTION(WARN_MISSING_SYSTEM_LDAP OUTPUT_WARNING)
IF(NOT LDAP_FOUND AND WITH_LDAP STREQUAL "system")
MESSAGE(WARNING "Cannot find LDAP development libraries. "
"You need to install the required packages:\n"
" Debian/Ubuntu: apt install libldap-dev\n"
" RedHat/Fedora/Oracle Linux: yum install openldap-devel\n"
" SuSE: zypper install openldap2-devel\n"
)
SET(${OUTPUT_WARNING} 1 PARENT_SCOPE)
ENDIF()
ENDFUNCTION()
MACRO(FIND_SYSTEM_LDAP)
IF(WIN32)
SET(LDAP_SYSTEM_LIBRARY Wldap32 CACHE INTERNAL
"LDAP library is /c/Windows/system32/Wldap32.dll"
)
ELSE()
FIND_LIBRARY(LDAP_SYSTEM_LIBRARY
NAMES ldap_r ldap
)
FIND_LIBRARY(LBER_SYSTEM_LIBRARY
NAMES lber
)
ENDIF()
IF(LDAP_SYSTEM_LIBRARY AND (WIN32 OR LBER_SYSTEM_LIBRARY))
SET(LDAP_LIBRARY ${LDAP_SYSTEM_LIBRARY})
SET(LBER_LIBRARY ${LBER_SYSTEM_LIBRARY})
MESSAGE(STATUS "LBER_LIBRARY ${LBER_LIBRARY}")
MESSAGE(STATUS "LDAP_LIBRARY ${LDAP_LIBRARY}")
ENDIF()
IF(WIN32)
# LDAP system header is Winldap.h and is in some Windows SDK
ELSE()
CMAKE_PUSH_CHECK_STATE()
# For Solaris 11.3 we need to explicitly search here:
IF(SOLARIS)
INCLUDE_DIRECTORIES(BEFORE SYSTEM /usr/include/openldap)
SET(CMAKE_REQUIRED_INCLUDES "/usr/include/openldap")
ENDIF()
CHECK_INCLUDE_FILE(lber.h HAVE_LBER_H)
CHECK_INCLUDE_FILE(ldap.h HAVE_LDAP_H)
CMAKE_POP_CHECK_STATE()
ENDIF()
ENDMACRO()
MACRO(FIND_CUSTOM_LDAP)
FIND_PATH(LDAP_INCLUDE_DIR
NAMES ldap.h
PATHS ${WITH_LDAP_PATH}/include
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
)
FIND_LIBRARY(LDAP_CUSTOM_LIBRARY
NAMES ldap_r ldap
PATHS ${WITH_LDAP_PATH}/lib
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
)
FIND_LIBRARY(LBER_CUSTOM_LIBRARY
NAMES lber
PATHS ${WITH_LDAP_PATH}/lib
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
)
IF(LDAP_INCLUDE_DIR)
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${LDAP_INCLUDE_DIR})
CMAKE_PUSH_CHECK_STATE()
SET(CMAKE_REQUIRED_INCLUDES ${LDAP_INCLUDE_DIR})
CHECK_INCLUDE_FILE(lber.h HAVE_LBER_H)
CHECK_INCLUDE_FILE(ldap.h HAVE_LDAP_H)
CMAKE_POP_CHECK_STATE()
ENDIF()
IF(LDAP_CUSTOM_LIBRARY AND LBER_CUSTOM_LIBRARY)
SET(LDAP_LIBRARY ${LDAP_CUSTOM_LIBRARY})
SET(LBER_LIBRARY ${LBER_CUSTOM_LIBRARY})
MESSAGE(STATUS "LDAP_LIBRARY ${LDAP_LIBRARY}")
MESSAGE(STATUS "LBER_LIBRARY ${LBER_LIBRARY}")
ENDIF()
ENDMACRO()
MACRO(MYSQL_CHECK_LDAP)
IF(NOT WITH_LDAP)
SET(WITH_LDAP "system" CACHE STRING ${WITH_LDAP_DOC_STRING} FORCE)
ENDIF()
# See if WITH_LDAP is of the form </path/to/custom/installation>
FILE(GLOB WITH_LDAP_HEADER ${WITH_LDAP}/include/ldap.h)
IF (WITH_LDAP_HEADER)
FILE(TO_CMAKE_PATH "${WITH_LDAP}" WITH_LDAP)
SET(WITH_LDAP_PATH ${WITH_LDAP})
ENDIF()
IF(WITH_LDAP STREQUAL "system")
FIND_SYSTEM_LDAP()
ELSEIF(WITH_LDAP_PATH)
IF(LINUX_STANDALONE)
FIND_CUSTOM_LDAP()
ELSE()
MESSAGE(FATAL_ERROR "-DWITH_LDAP=<path> not supported on this platform")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "Could not find LDAP")
ENDIF()
IF(WIN32 AND WITH_LDAP STREQUAL "system")
SET(LDAP_FOUND 1)
ELSEIF(HAVE_LBER_H AND HAVE_LDAP_H AND LDAP_LIBRARY AND LBER_LIBRARY)
SET(LDAP_FOUND 1)
ELSE()
SET(LDAP_FOUND 0)
# FATAL_ERROR later if WITH_AUTHENTICATION_LDAP == ON
MESSAGE(WARNING "Could not find LDAP")
ENDIF()
ENDMACRO()
MACRO(MYSQL_CHECK_LDAP_DLLS)
IF(LINUX_STANDALONE AND LDAP_CUSTOM_LIBRARY)
COPY_CUSTOM_SHARED_LIBRARY("${LDAP_CUSTOM_LIBRARY}" ""
LDAP_LIBRARY ldap_target)
ENDIF()
IF(LINUX_STANDALONE AND LBER_CUSTOM_LIBRARY)
COPY_CUSTOM_SHARED_LIBRARY("${LBER_CUSTOM_LIBRARY}" ""
LBER_LIBRARY lber_target)
ENDIF()
ENDMACRO()
|