/ cmake / module / FindQRencode.cmake
FindQRencode.cmake
 1  # Copyright (c) 2024-present The Bitcoin Core developers
 2  # Distributed under the MIT software license, see the accompanying
 3  # file COPYING or https://opensource.org/license/mit/.
 4  
 5  #[=======================================================================[
 6  FindQRencode
 7  ------------
 8  
 9  Finds the QRencode header and library.
10  
11  This is a wrapper around find_package()/pkg_check_modules() commands that:
12   - facilitates searching in various build environments
13   - prints a standard log message
14  
15  #]=======================================================================]
16  
17  find_package(PkgConfig QUIET)
18  if(PKG_CONFIG_FOUND)
19    pkg_check_modules(PC_QRencode QUIET libqrencode)
20  endif()
21  
22  find_path(QRencode_INCLUDE_DIR
23    NAMES qrencode.h
24    HINTS ${PC_QRencode_INCLUDE_DIRS}
25  )
26  
27  find_library(QRencode_LIBRARY_RELEASE
28    NAMES qrencode
29    HINTS ${PC_QRencode_LIBRARY_DIRS}
30  )
31  find_library(QRencode_LIBRARY_DEBUG
32    NAMES qrencoded qrencode
33    HINTS ${PC_QRencode_LIBRARY_DIRS}
34  )
35  include(SelectLibraryConfigurations)
36  select_library_configurations(QRencode)
37  
38  include(FindPackageHandleStandardArgs)
39  find_package_handle_standard_args(QRencode
40    REQUIRED_VARS QRencode_LIBRARY QRencode_INCLUDE_DIR
41    VERSION_VAR PC_QRencode_VERSION
42  )
43  
44  if(QRencode_FOUND)
45    if(NOT TARGET QRencode::QRencode)
46      add_library(QRencode::QRencode UNKNOWN IMPORTED)
47    endif()
48    if(QRencode_LIBRARY_RELEASE)
49      set_property(TARGET QRencode::QRencode APPEND PROPERTY
50        IMPORTED_CONFIGURATIONS RELEASE
51      )
52      set_target_properties(QRencode::QRencode PROPERTIES
53        IMPORTED_LOCATION_RELEASE "${QRencode_LIBRARY_RELEASE}"
54      )
55    endif()
56    if(QRencode_LIBRARY_DEBUG)
57      set_property(TARGET QRencode::QRencode APPEND PROPERTY
58        IMPORTED_CONFIGURATIONS DEBUG
59      )
60      set_target_properties(QRencode::QRencode PROPERTIES
61        IMPORTED_LOCATION_DEBUG "${QRencode_LIBRARY_DEBUG}"
62      )
63    endif()
64    set_target_properties(QRencode::QRencode PROPERTIES
65      INTERFACE_INCLUDE_DIRECTORIES "${QRencode_INCLUDE_DIR}"
66    )
67  endif()
68  
69  mark_as_advanced(
70    QRencode_INCLUDE_DIR
71  )