cmake: Add application manifests when cross-compiling for Windows

Windows application manifests provide several benefits. However, on the
master branch, the linker generates and embeds manifests only when
building with MSVC.

This change unifies manifest embedding for both native and
cross-compilation.
This commit is contained in:
Hennadii Stepanov committed 2025-05-15 13:57:57 +01:00
1 parent 663a9cabf8
commit 282b4913c7
6 files changed
+42 -2

No files matched your search

+4
View File
@@ -276,6 +276,10 @@ if(WIN32)
/Zc:__cplusplus
/sdl
)
target_link_options(core_interface INTERFACE
# We embed our own manifests.
/MANIFEST:NO
)
# Improve parallelism in MSBuild.
# See: https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/.
list(APPEND CMAKE_VS_GLOBALS "UseMultiToolTask=true")
+15 -2
View File
@@ -4,11 +4,24 @@
include_guard(GLOBAL)
macro(add_windows_resources target rc_file)
function(add_windows_resources target rc_file)
if(WIN32)
target_sources(${target} PRIVATE ${rc_file})
set_property(SOURCE ${rc_file}
APPEND PROPERTY COMPILE_DEFINITIONS WINDRES_PREPROC
)
endif()
endmacro()
endfunction()
# Add a fusion manifest to Windows executables.
# See: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
function(add_windows_application_manifest target)
if(WIN32)
configure_file(${PROJECT_SOURCE_DIR}/cmake/windows-app.manifest.in ${target}.manifest USE_SOURCE_PERMISSIONS)
file(CONFIGURE
OUTPUT ${target}-manifest.rc
CONTENT "1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ \"${target}.manifest\""
)
add_windows_resources(${target} ${CMAKE_CURRENT_BINARY_DIR}/${target}-manifest.rc)
endif()
endfunction()
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="org.bitcoincore.${target}"
version="${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_BUILD}.0"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
+5
View File
@@ -206,6 +206,7 @@ if(ENABLE_WALLET)
wallet/wallettool.cpp
)
add_windows_resources(bitcoin-wallet bitcoin-wallet-res.rc)
add_windows_application_manifest(bitcoin-wallet)
target_link_libraries(bitcoin-wallet
core_interface
bitcoin_wallet
@@ -339,6 +340,7 @@ if(BUILD_DAEMON)
init/bitcoind.cpp
)
add_windows_resources(bitcoind bitcoind-res.rc)
add_windows_application_manifest(bitcoind)
target_link_libraries(bitcoind
core_interface
bitcoin_node
@@ -392,6 +394,7 @@ target_link_libraries(bitcoin_cli
if(BUILD_CLI)
add_executable(bitcoin-cli bitcoin-cli.cpp)
add_windows_resources(bitcoin-cli bitcoin-cli-res.rc)
add_windows_application_manifest(bitcoin-cli)
target_link_libraries(bitcoin-cli
core_interface
bitcoin_cli
@@ -407,6 +410,7 @@ endif()
if(BUILD_TX)
add_executable(bitcoin-tx bitcoin-tx.cpp)
add_windows_resources(bitcoin-tx bitcoin-tx-res.rc)
add_windows_application_manifest(bitcoin-tx)
target_link_libraries(bitcoin-tx
core_interface
bitcoin_common
@@ -420,6 +424,7 @@ endif()
if(BUILD_UTIL)
add_executable(bitcoin-util bitcoin-util.cpp)
add_windows_resources(bitcoin-util bitcoin-util-res.rc)
add_windows_application_manifest(bitcoin-util)
target_link_libraries(bitcoin-util
core_interface
bitcoin_common
+1
View File
@@ -256,6 +256,7 @@ add_executable(bitcoin-qt
)
add_windows_resources(bitcoin-qt res/bitcoin-qt-res.rc)
add_windows_application_manifest(bitcoin-qt)
target_link_libraries(bitcoin-qt
core_interface
+2
View File
@@ -142,6 +142,8 @@ target_raw_data_sources(test_bitcoin NAMESPACE test::data
data/asmap.raw
)
add_windows_application_manifest(test_bitcoin)
target_link_libraries(test_bitcoin
core_interface
test_util