1#############################################################################
2# Copyright (c) 2016 Balabit
3#
4# This library is free software; you can redistribute it and/or
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
8#
9# This library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12# Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public
15# License along with this library; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17#
18# As an additional exemption you are allowed to compile & link against the
19# OpenSSL libraries as published by the OpenSSL project. See the file
20# COPYING for details.
21#
22#############################################################################
23
24# Origin: https://raw.githubusercontent.com/ckruse/cforum_cpp/master/cmake/modules/FindESMTP.cmake
25# - Try to find the libesmtp library
26# Once done this will define
27#
28#  ESMTP_FOUND - system has the libesmtp library
29#  ESMTP_CONFIG
30#  ESMTP_INCLUDE_DIR - the libesmtp include directory
31#  ESMTP_LIBRARIES - The libraries needed to use libesmtp
32#
33# Based on FindPCRE.cmake
34# Distributed under the BSD license.
35
36if (ESMTP_INCLUDE_DIR AND ESMTP_LIBRARIES)
37  # Already in cache, be silent
38  set(ESMTP_FIND_QUIETLY TRUE)
39endif (ESMTP_INCLUDE_DIR AND ESMTP_LIBRARIES)
40
41find_package(PkgConfig)
42pkg_check_modules(PC_ESMTP QUIET libesmtp-1.0)
43
44if (PC_ESMTP_FOUND)
45  find_path(ESMTP_INCLUDE_DIR NAMES libesmtp.h HINTS ${PC_ESMTP_INCLUDE_DIRS} PATH_SUFFIXES libesmtp)
46  find_library(ESMTP_LIBRARIES NAMES esmtp HINTS ${PC_ESMTP_LIBRARY_DIRS})
47else ()
48  find_program(ESMTP_CONFIG libesmtp-config)
49
50  if (ESMTP_CONFIG)
51    find_path(ESMTP_INCLUDE_DIR libesmtp.h )
52    exec_program(${ESMTP_CONFIG} ARGS --libs OUTPUT_VARIABLE _ESMTP_LIBRARIES)
53    string(REGEX REPLACE "[\r\n]" " " _ESMTP_LIBRARIES "${_ESMTP_LIBRARIES}")
54    set (ESMTP_LIBRARIES ${_ESMTP_LIBRARIES} CACHE STRING "The libraries needed for ESMTP")
55  endif (ESMTP_CONFIG)
56endif (PC_ESMTP_FOUND)
57
58include(FindPackageHandleStandardArgs)
59find_package_handle_standard_args(ESMTP DEFAULT_MSG ESMTP_LIBRARIES ESMTP_INCLUDE_DIR)
60mark_as_advanced(ESMTP_LIBRARIES ESMTP_INCLUDE_DIR)
61