Skip to content

Commit 67e9424

Browse files
committed
Improve library dependencies for Windows builds
Due to a change in MSYS2, Boost::locale now links statically by default, which in turn causes CMake not to find the dynamically linked DLLs for ICU during packaging of the release build. Setting Boost_USE_STATIC_LIBS forces dynamic linking of Boost::locale and assumes that the DLLs for ICU can be found at the same path as those for Boost::locale during packaging of the release build. Use CMake's LOCATION property to retrieve the location of dependencies that are IMPORTED targets. This will still be problematic for static dependencies that themselves have DLLs as dependencies but there doesn't appear to be an elegant CMake solution to address this. The $<PATH:GET_PARENT_PATH,...> generator requires CMake >=3.24 which is fine because Windows release builds already assume a very up-to-date build environment. Exclude the C/C++ runtime from the runtime dependency set of library targets to avoid ambiguity if multiple C/C++ toolchains are available. Instead, let windeployqt be fully responsible for providing the C/C++ runtime.
1 parent e219acc commit 67e9424

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.github/workflows/windows-build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ jobs:
160160
-DCMAKE_C_COMPILER="${{ env.TOOLCHAIN_PATH }}/gcc.exe" \
161161
-DCMAKE_CXX_COMPILER="${{ env.TOOLCHAIN_PATH }}/g++.exe" \
162162
-DBUILD_SHARED_LIBS=YES \
163+
-DBoost_USE_STATIC_LIBS=NO \
163164
-DFETCH_MBEDTLS=YES \
164165
-DFETCH_ARGP=YES \
165166
-DBUILD_EMV_DECODE=YES \

src/CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ install(
248248
COMPONENT emv_development
249249
)
250250
if(WIN32 AND BUILD_WIN_STANDALONE)
251-
if(${CMAKE_VERSION} VERSION_LESS "3.21")
252-
message(FATAL_ERROR "CMake >=3.21 is required to install dependencies on Windows")
251+
if(${CMAKE_VERSION} VERSION_LESS "3.24")
252+
message(FATAL_ERROR "CMake >=3.24 is required to install dependencies on Windows")
253253
endif()
254254

255255
install(
@@ -260,13 +260,13 @@ if(WIN32 AND BUILD_WIN_STANDALONE)
260260
install(
261261
RUNTIME_DEPENDENCY_SET iso8859_deps
262262
PRE_EXCLUDE_REGEXES
263-
"api-ms-"
263+
"^api-ms-"
264+
"^lib(gcc|stdc\\+\\+|winpthread)"
264265
POST_EXCLUDE_REGEXES
265266
"system32"
266267
DIRECTORIES
267-
$<$<STREQUAL:${ISO8859_IMPL},boost>:$<$<TARGET_EXISTS:Boost::locale>:$<TARGET_FILE_DIR:Boost::locale>>>
268+
$<$<STREQUAL:${ISO8859_IMPL},boost>:$<$<TARGET_EXISTS:Boost::locale>:$<PATH:GET_PARENT_PATH,$<TARGET_PROPERTY:Boost::locale,LOCATION>>>>
268269
$<$<STREQUAL:${ISO8859_IMPL},iconv>:$<$<BOOL:${Iconv_LIBRARIES}>:$<TARGET_FILE_DIR:Iconv::Iconv>>>
269-
270270
RUNTIME
271271
COMPONENT emv_runtime
272272
)
@@ -413,8 +413,8 @@ install(
413413
COMPONENT emv_development
414414
)
415415
if(WIN32 AND BUILD_WIN_STANDALONE)
416-
if(${CMAKE_VERSION} VERSION_LESS "3.21")
417-
message(FATAL_ERROR "CMake >=3.21 is required to install dependencies on Windows")
416+
if(${CMAKE_VERSION} VERSION_LESS "3.24")
417+
message(FATAL_ERROR "CMake >=3.24 is required to install dependencies on Windows")
418418
endif()
419419

420420
install(
@@ -425,11 +425,12 @@ if(WIN32 AND BUILD_WIN_STANDALONE)
425425
install(
426426
RUNTIME_DEPENDENCY_SET emv_strings_deps
427427
PRE_EXCLUDE_REGEXES
428-
"api-ms-"
428+
"^api-ms-"
429+
"^lib(gcc|stdc\\+\\+|winpthread)"
429430
POST_EXCLUDE_REGEXES
430431
"system32"
431432
DIRECTORIES
432-
$<$<TARGET_EXISTS:json-c::json-c>:$<TARGET_FILE_DIR:json-c::json-c>>
433+
$<$<TARGET_EXISTS:json-c::json-c>:$<PATH:GET_PARENT_PATH,$<TARGET_PROPERTY:json-c::json-c,LOCATION>>>
433434
RUNTIME
434435
COMPONENT emv_runtime
435436
)

0 commit comments

Comments
 (0)