diff --git a/linphone-app/CMakeLists.txt b/linphone-app/CMakeLists.txt index 0d2f98dcc..ecb9aa745 100644 --- a/linphone-app/CMakeLists.txt +++ b/linphone-app/CMakeLists.txt @@ -725,18 +725,7 @@ if(ENABLE_QT_KEYCHAIN) list(APPEND LIBRARIES_LIST ${QtKeyChain_LIBRARIES}) endif() -if(WIN32) - foreach(LIBRARY ${LIBRARIES_LIST})# Search for lib full path - find_library(FIND_LIBRARY_ITEM_${LIBRARY} NAMES ${LIBRARY} lib${LIBRARY} REQUIRED)#find_library need a specific variable name each time - if(FIND_LIBRARY_ITEM_${LIBRARY}) - list(APPEND LIBRARIES ${FIND_LIBRARY_ITEM_${LIBRARY}}) - else() - message(SEND_ERROR "${LIBRARY} not found!") - endif() - endforeach() -else() - list(APPEND LIBRARIES ${LIBRARIES_LIST}) -endif() +list(APPEND LIBRARIES ${LIBRARIES_LIST}) if(ENABLE_BUILD_VERBOSE) message("LIBRARIES : ${LIBRARIES}") @@ -777,10 +766,9 @@ target_link_libraries(${APP_LIBRARY} ${APP_PLUGIN}) target_link_libraries(${TARGET_NAME} ${LIBRARIES}) target_link_libraries(${TARGET_NAME} ${APP_PLUGIN}) -if(WIN32) - find_library(LDAP_LIBRARIES NAMES ldap libldap HINTS "${LINPHONE_OUTPUT_DIR}/${CMAKE_INSTALL_LIBDIR}") - find_library(LBER_LIBRARIES NAMES lber liblber HINTS "${LINPHONE_OUTPUT_DIR}/${CMAKE_INSTALL_LIBDIR}") - target_link_libraries(${TARGET_NAME} wsock32 ws2_32 ${LDAP_LIBRARIES} ${LBER_LIBRARIES}) +if(WIN32 AND ENABLE_LDAP) + find_package(OpenLDAP REQUIRED) + target_link_libraries(${TARGET_NAME} wsock32 ws2_32 ${OPENLDAP_LIBRARIES}) endif() add_dependencies(${APP_LIBRARY} update_translations ${TARGET_NAME}-git-version ${APP_PLUGIN}) diff --git a/linphone-app/cmake/FindOpenLDAP.cmake b/linphone-app/cmake/FindOpenLDAP.cmake new file mode 100644 index 000000000..8fc1b0063 --- /dev/null +++ b/linphone-app/cmake/FindOpenLDAP.cmake @@ -0,0 +1,83 @@ +############################################################################ +# Copyright (c) 2021-2023 Belledonne Communications SARL. +# +# This file is part of liblinphone. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################ +# +# - Find the OpenLDAP include file and library +# +# OPENLDAP_FOUND - system has OpenLDAP +# OPENLDAP_INCLUDE_DIRS - the OpenLDAP include directory +# OPENLDAP_LIBRARIES - The libraries needed to use OpenLDAP + +if(TARGET ldap) + + set(OPENLDAP_LIBRARIES ldap) + get_target_property(OPENLDAP_INCLUDE_DIRS ldap INTERFACE_INCLUDE_DIRECTORIES) + +else() + + #Note : There are double find* because of priority given to the HINTS first. The second call will keep the result if there is one. + #INCLUDES + find_path(OPENLDAP_INCLUDE_DIRS + NAMES ldap.h + PATH_SUFFIXES include/openldap + HINTS "${CMAKE_INSTALL_PREFIX}" + NO_DEFAULT_PATH + ) + find_path(OPENLDAP_INCLUDE_DIRS + NAMES ldap.h + PATH_SUFFIXES include/openldap + HINTS "${CMAKE_INSTALL_PREFIX}" + ) + + #LDAP + find_library(LDAP_LIB + NAMES ldap libldap + HINTS "${CMAKE_INSTALL_PREFIX}" + PATH_SUFFIXES lib + NO_DEFAULT_PATH + ) + find_library(LDAP_LIB + NAMES ldap libldap + HINTS "${CMAKE_INSTALL_PREFIX}" + PATH_SUFFIXES lib + ) + + #LBER + find_library(LBER_LIB + NAMES lber liblber + HINTS "${CMAKE_INSTALL_PREFIX}" + PATH_SUFFIXES lib + NO_DEFAULT_PATH + ) + find_library(LBER_LIB + NAMES lber liblber + HINTS "${CMAKE_INSTALL_PREFIX}" + PATH_SUFFIXES lib + ) + set(OPENLDAP_LIBRARIES ${LDAP_LIB} ${LBER_LIB}) + +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenLDAP + DEFAULT_MSG + OPENLDAP_INCLUDE_DIRS OPENLDAP_LIBRARIES +) + +mark_as_advanced(OPENLDAP_INCLUDE_DIRS OPENLDAP_LIBRARIES)