CMake file for novacoind (USE_LEVELDB does not work yet)
[novacoin.git] / src / additional / cmake / FindQREncode.cmake
1 # Copyright (c) 2019-2020 The Bitcoin developers
2 # Distributed under the MIT software license, see the accompanying
3 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5 #.rst
6 # FindQREncode
7 # -------------
8 #
9 # Find the QREncode library. The following
10 # components are available::
11 #   qrencode
12 #
13 # This will define the following variables::
14 #
15 #   QREncode_FOUND - system has QREncode lib
16 #   QREncode_INCLUDE_DIRS - the QREncode include directories
17 #   QREncode_LIBRARIES - Libraries needed to use QREncode
18 #
19 # And the following imported target::
20 #
21 #   QREncode::qrencode
22
23 include(BrewHelper)
24 find_brew_prefix(_QREncode_BREW_HINT qrencode)
25
26 find_package(PkgConfig)
27 pkg_check_modules(PC_QREncode QUIET libqrencode)
28
29 find_path(QREncode_INCLUDE_DIR
30         NAMES qrencode.h
31         HINTS ${_QREncode_BREW_HINT}
32         PATHS ${PC_QREncode_INCLUDE_DIRS}
33         PATH_SUFFIXES include
34 )
35
36 set(QREncode_INCLUDE_DIRS "${QREncode_INCLUDE_DIR}")
37 mark_as_advanced(QREncode_INCLUDE_DIR)
38
39 # TODO: extract a version number.
40 # For now qrencode does not provide an easy way to extract a version number.
41
42 if(QREncode_INCLUDE_DIR)
43         include(ExternalLibraryHelper)
44         find_component(QREncode qrencode
45                 NAMES qrencode
46                 HINTS ${_QREncode_BREW_HINT}
47                 PATHS ${PC_QREncode_LIBRARY_DIRS}
48                 INCLUDE_DIRS ${QREncode_INCLUDE_DIRS}
49         )
50 endif()
51
52 include(FindPackageHandleStandardArgs)
53 find_package_handle_standard_args(QREncode
54         REQUIRED_VARS
55                 QREncode_INCLUDE_DIR
56                 REASON_FAILURE_MESSAGE "if displaying QR codes is not required, it can be skipped by passing -DENABLE_QRCODE=OFF to the cmake command line"
57         HANDLE_COMPONENTS
58 )