Skip to content

Commit 30089b0

Browse files
committed
cmake: Add FindQRencode module
1 parent 65b1941 commit 30089b0

File tree

3 files changed

+73
-3
lines changed

3 files changed

+73
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support."
135135

136136
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
137137
if(WITH_QRENCODE)
138-
find_package(PkgConfig REQUIRED)
139-
pkg_check_modules(libqrencode REQUIRED IMPORTED_TARGET libqrencode)
138+
find_package(QRencode MODULE REQUIRED)
140139
set(USE_QRCODE TRUE)
141140
endif()
142141

cmake/module/FindQRencode.cmake

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
PATHS ${PC_QRencode_INCLUDE_DIRS}
25+
)
26+
27+
find_library(QRencode_LIBRARY_RELEASE
28+
NAMES qrencode
29+
PATHS ${PC_QRencode_LIBRARY_DIRS}
30+
)
31+
find_library(QRencode_LIBRARY_DEBUG
32+
NAMES qrencoded qrencode
33+
PATHS ${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+
)

src/qt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ target_link_libraries(bitcoinqt
133133
bitcoin_cli
134134
leveldb
135135
Boost::headers
136-
$<TARGET_NAME_IF_EXISTS:PkgConfig::libqrencode>
136+
$<TARGET_NAME_IF_EXISTS:QRencode::QRencode>
137137
$<$<PLATFORM_ID:Darwin>:-framework\ AppKit>
138138
$<$<CXX_COMPILER_ID:MSVC>:shlwapi>
139139
)

0 commit comments

Comments
 (0)