Skip to content

Commit 7343a18

Browse files
committed
depends: Avoid using helper variables in toolchain file
Using helper variables has two issues: 1. They contaminate the global namespace of the main build script. 2. They can be used as `set(var)`, effectively exposing a cache variable `var`, which makes the toolchain file susceptible to the build environment.
1 parent efac285 commit 7343a18

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

depends/toolchain.cmake.in

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,37 +115,35 @@ endif()
115115

116116

117117
# Set configuration options for the main build system.
118-
set(qt_packages @qt_packages@)
119-
if("${qt_packages}" STREQUAL "")
118+
# The depends/Makefile can generate values with "not-set"
119+
# semantics as empty strings or strings containing only spaces.
120+
# Therefore, MATCHES must be used rather than STREQUAL.
121+
if("@qt_packages@" MATCHES "^[ ]*$")
120122
set(BUILD_GUI OFF CACHE BOOL "")
121123
else()
122124
set(BUILD_GUI ON CACHE BOOL "")
123125
set(Qt6_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "")
124126
endif()
125127

126-
set(qrencode_packages @qrencode_packages@)
127-
if("${qrencode_packages}" STREQUAL "")
128+
if("@qrencode_packages@" MATCHES "^[ ]*$")
128129
set(WITH_QRENCODE OFF CACHE BOOL "")
129130
else()
130131
set(WITH_QRENCODE ON CACHE BOOL "")
131132
endif()
132133

133-
set(zmq_packages @zmq_packages@)
134-
if("${zmq_packages}" STREQUAL "")
134+
if("@zmq_packages@" MATCHES "^[ ]*$")
135135
set(WITH_ZMQ OFF CACHE BOOL "")
136136
else()
137137
set(WITH_ZMQ ON CACHE BOOL "")
138138
endif()
139139

140-
set(wallet_packages @wallet_packages@)
141-
if("${wallet_packages}" STREQUAL "")
140+
if("@wallet_packages@" MATCHES "^[ ]*$")
142141
set(ENABLE_WALLET OFF CACHE BOOL "")
143142
else()
144143
set(ENABLE_WALLET ON CACHE BOOL "")
145144
endif()
146145

147-
set(usdt_packages @usdt_packages@)
148-
if("${usdt_packages}" STREQUAL "")
146+
if("@usdt_packages@" MATCHES "^[ ]*$")
149147
set(WITH_USDT OFF CACHE BOOL "")
150148
else()
151149
set(WITH_USDT ON CACHE BOOL "")

0 commit comments

Comments
 (0)