summaryrefslogtreecommitdiff
path: root/CMake/FindIDN2.cmake
blob: c7a85149d21d7c7ef333aafab55893b06176ecf8 (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
69
# - Try to find idn2
# Once done this will define
#
#  IDN2_FOUND - system has idn2
#  IDN2_INCLUDE_DIRS - the idn2 include directory
#  IDN2_LIBRARIES - Link these to use idn2
#  IDN2_DEFINITIONS - Compiler switches required for using idn2
#
#=============================================================================
#  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 (IDN2_LIBRARIES AND IDN2_INCLUDE_DIRS)
    # in cache already
    # set(IDN2_FOUND TRUE)
else (IDN2_LIBRARIES AND IDN2_INCLUDE_DIRS)

    set(_IDN2_ROOT_PATHS
        "$ENV{PROGRAMFILES}/libidn2"
    )

    find_path(IDN2_ROOT_DIR
        NAMES
            include/idn2.h
        PATHS
            ${_IDN2_ROOT_PATHS}
    )
    mark_as_advanced(IDN2_ROOT_DIR)

    find_path(IDN2_INCLUDE_DIR
        NAMES
            idn2.h
	    idn2/idn2.h
        PATHS
            /usr/local/include
            /opt/local/include
            /sw/include
            /usr/lib/sfw/include
            ${IDN2_ROOT_DIR}/include
    )
    set(IDN2_INCLUDE_DIRS ${IDN2_INCLUDE_DIR})

    find_library(IDN2_LIBRARY
        NAMES
            libidn2
        PATHS
            /opt/local/lib
            /sw/lib
            /usr/sfw/lib/64
            /usr/sfw/lib
	    ${IDN2_ROOT_DIR}/lib
    )
    set(IDN2_LIBRARIES ${IDN2_LIBRARY})

    include(FindPackageHandleStandardArgs)
    find_package_handle_standard_args(IDN2 DEFAULT_MSG IDN2_LIBRARIES IDN2_INCLUDE_DIRS)

    # show the IDN2_INCLUDE_DIRS and IDN2_LIBRARIES variables only in the advanced view
    mark_as_advanced(IDN2_INCLUDE_DIRS IDN2_LIBRARIES)

endif (IDN2_LIBRARIES AND IDN2_INCLUDE_DIRS)