Skip to content

Runtimes: make resource embedding work on Windows #79407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Runtimes/Core/cmake/modules/ResourceEmbedding.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ function(generate_plist project_name project_version target)
endif()
endfunction()

if(NOT DEFINED CMAKE_MT)
find_program(CMAKE_MT NAMES mt llvm-mt)
# FIXME: it appears that `CMAKE_MT` evaluates to an empty string which prevents
# the use of the variable. This aliases `MT` to `CMAKE_MT` and tries to fallback
# to known spellings for the tool.
if(WIN32 AND BUILD_SHARED_LIBS)
find_program(MT HINTS ${CMAKE_MT} NAMES mt llvm-mt REQUIRED)
endif()

function(embed_manifest target)
Expand Down Expand Up @@ -62,6 +65,6 @@ function(embed_manifest target)

if(WIN32)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_MT} -nologo -manifest "${_EM_BINARY_DIR}/${_EM_NAME}-${PROJECT_VERSION}.1.manifest" "-outputresource:$<TARGET_FILE:${target}>;#1")
COMMAND "${MT}" -nologo -manifest "${_EM_BINARY_DIR}/${_EM_NAME}-${PROJECT_VERSION}.1.manifest" "-outputresource:$<TARGET_FILE:${target}>;#1")
endif()
endfunction()