aboutsummaryrefslogtreecommitdiff
path: root/CMake/FindIDN.cmake
blob: 76921f776ad373708f1f8d5ce0f61f4e67dd1272 (plain)
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
# - Try to find idn
# Once done this will define
#
#  IDN_FOUND - system has idn
#  IDN_INCLUDE_DIRS - the idn include directory
#  IDN_LIBRARIES - Link these to use idn
#  IDN_DEFINITIONS - Compiler switches required for using idn
#
#=============================================================================
#  Copyright (c) 2019 ng0 <ng0@n0.is>
#
#  Distributed under the OSI-approved 0BSD License.
#
#  This software is distributed WITHOUT ANY WARRANTY; without even the
#  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#  See the License for more information.
#=============================================================================
#

if (IDN_LIBRARIES AND IDN_INCLUDE_DIRS)
    # in cache already
    # set(IDN_FOUND TRUE)
else (IDN_LIBRARIES AND IDN_INCLUDE_DIRS)

    set(_IDN_ROOT_PATHS
        "$ENV{PROGRAMFILES}/libidn"
    )

    find_path(IDN_ROOT_DIR
        NAMES
	include/idna.h
        PATHS
            ${_IDN_ROOT_PATHS}
    )
    mark_as_advanced(IDN_ROOT_DIR)

    find_path(IDN_INCLUDE_DIR
        NAMES
            idna.h
        PATHS
            /usr/local/include
            /opt/local/include
            /sw/include
            /usr/lib/sfw/include
            ${IDN_ROOT_DIR}/include
    )
    set(IDN_INCLUDE_DIRS ${IDN_INCLUDE_DIR})

    find_library(IDN_LIBRARY
        NAMES
            libidn
        PATHS
            /opt/local/lib
            /sw/lib
            /usr/sfw/lib/64
            /usr/sfw/lib
	    ${IDN_ROOT_DIR}/lib
    )
    set(IDN_LIBRARIES ${IDN_LIBRARY})

    include(FindPackageHandleStandardArgs)
    find_package_handle_standard_args(IDN DEFAULT_MSG IDN_LIBRARIES IDN_INCLUDE_DIRS)

    # show the IDN_INCLUDE_DIRS and IDN_LIBRARIES variables only in the advanced view
    mark_as_advanced(IDN_INCLUDE_DIRS IDN_LIBRARIES)

endif (IDN_LIBRARIES AND IDN_INCLUDE_DIRS)