1# BAREOS® - Backup Archiving REcovery Open Sourced 2# 3# Copyright (C) 2017-2019 Bareos GmbH & Co. KG 4# 5# This program is Free Software; you can redistribute it and/or 6# modify it under the terms of version three of the GNU Affero General Public 7# License as published by the Free Software Foundation and included 8# in the file LICENSE. 9# 10# This program is distributed in the hope that it will be useful, but 11# WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13# Affero General Public License for more details. 14# 15# You should have received a copy of the GNU Affero General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18# 02110-1301, USA. 19 20# generic macro to find libraries 21 22MACRO(BareosFindLibrary LIBNAME) 23 MESSAGE(STATUS "checking for library ${LIBNAME}...") 24 25 STRING(TOUPPER ${LIBNAME} LIBNAME_UPCASE) 26 SET(INCLUDE_VAR_NAME ${LIBNAME_UPCASE}_INCLUDE_DIRS) 27 SET(LIB_VAR_NAME ${LIBNAME_UPCASE}_LIBRARIES) 28 SET(FOUND_VAR_NAME ${LIBNAME_UPCASE}_FOUND) 29 SET(HAVE_VAR_NAME HAVE_LIB${LIBNAME_UPCASE}) 30 31 32 find_library(${LIB_VAR_NAME} NAMES ${LIBNAME}) 33 34 35 SET(LIBFOUND ${${LIB_VAR_NAME}}) 36 37 STRING(REGEX MATCH "-NOTFOUND" LIBNOTFOUND ${LIBFOUND}) 38 #MESSAGE(STATUS "LIB REGEX MATCH: ${LIBNOTFOUND}") 39 STRING(LENGTH "${LIBNOTFOUND}" LIBNOTFOUND ) 40 41 if (NOT ${LIBNOTFOUND}) 42 set(${FOUND_VAR_NAME} TRUE) 43 set(${HAVE_VAR_NAME} 1) 44 else() 45 set(${FOUND_VAR_NAME} FALSE) 46 set(${HAVE_VAR_NAME} 0) 47 endif () 48 49 50 51 SET(QUIETVALUE ${${QUIET_VAR_NAME}}) 52 SET(FOUNDVALUE ${${FOUND_VAR_NAME}}) 53 if (${FOUNDVALUE}) 54 message(STATUS " ${FOUND_VAR_NAME}=${${FOUND_VAR_NAME}}") 55 message(STATUS " ${LIB_VAR_NAME}=${${LIB_VAR_NAME}}") 56 message(STATUS " ${HAVE_VAR_NAME}=${${HAVE_VAR_NAME}}") 57 else () 58 message(STATUS " ERROR: ${LIBNAME} libraries NOT found. ") 59 60 set("${LIB_VAR_NAME}" "") 61 set("${INCLUDE_VAR_NAME}" "") 62 63 message(STATUS " ${FOUND_VAR_NAME}=${${FOUND_VAR_NAME}}") 64 message(STATUS " ${LIB_VAR_NAME}=${${LIB_VAR_NAME}}") 65 message(STATUS " ${HAVE_VAR_NAME}=${${HAVE_VAR_NAME}}") 66 endif () 67 68 mark_as_advanced( 69 ${LIB_VAR_NAME} 70 ${FOUND_VAR_NAME} 71 ) 72ENDMACRO() 73