Skip to content

Commit

Permalink
List utf8.manifest as normal source file for MSVC
Browse files Browse the repository at this point in the history
For toolchains targeting the MSVC ABI, CMake has first-class support for
embedding manifests. Manual embedding through a .rc source is needed
only when targeting the GNU ABI on Windows (MinGW).

Suggested by Brad King.

Fix AOMediaCodec#2442.
  • Loading branch information
wantehchang committed Sep 26, 2024
1 parent 2fe5b3a commit 4362ac6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
31 changes: 14 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -718,17 +718,12 @@ endif()
if(AVIF_BUILD_APPS)
add_executable(avifenc apps/avifenc.c)
if(WIN32)
# MinGW doesn't have a manifest tool (mt.exe), so we need to wrap
# utf8.manifest in a resource-definition script (.rc file).
target_sources(avifenc PRIVATE apps/utf8.rc)
# The MSVC linker (link.exe) fails with the following error if we
# don't use the /MANIFEST:NO linker option:
# /MANIFEST:EMBED,ID=1" failed (exit code 1123) with the following
# output:
# CVTRES : fatal error CVT1100: duplicate resource. type:MANIFEST,
# name:1, language:0x0409
if(NOT MINGW)
target_link_options(avifenc PRIVATE /MANIFEST:NO)
if(MSVC)
target_sources(avifenc PRIVATE apps/utf8.manifest)
elseif(MINGW)
# MinGW doesn't have a manifest tool (mt.exe), so we need to wrap
# utf8.manifest in a resource-definition script (.rc file).
target_sources(avifenc PRIVATE apps/utf8.rc)
endif()
endif()
if(AVIF_LIB_USE_CXX)
Expand All @@ -737,9 +732,10 @@ if(AVIF_BUILD_APPS)
target_link_libraries(avifenc avif_apps avif avif_enable_warnings)
add_executable(avifdec apps/avifdec.c)
if(WIN32)
target_sources(avifdec PRIVATE apps/utf8.rc)
if(NOT MINGW)
target_link_options(avifdec PRIVATE /MANIFEST:NO)
if(MSVC)
target_sources(avifdec PRIVATE apps/utf8.manifest)
elseif(MINGW)
target_sources(avifdec PRIVATE apps/utf8.rc)
endif()
endif()
if(AVIF_LIB_USE_CXX)
Expand Down Expand Up @@ -773,9 +769,10 @@ if(AVIF_BUILD_APPS)

add_executable(avifgainmaputil "${AVIFGAINMAPUTIL_SRCS}")
if(WIN32)
target_sources(avifgainmaputil PRIVATE apps/utf8.rc)
if(NOT MINGW)
target_link_options(avifgainmaputil PRIVATE /MANIFEST:NO)
if(MSVC)
target_sources(avifgainmaputil PRIVATE apps/utf8.manifest)
elseif(MINGW)
target_sources(avifgainmaputil PRIVATE apps/utf8.rc)
endif()
endif()
set_target_properties(avifgainmaputil PROPERTIES LINKER_LANGUAGE "CXX")
Expand Down
7 changes: 4 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ if(AVIF_BUILD_APPS)
# 'are_images_equal' is used to make sure inputs/outputs are unchanged.
add_executable(are_images_equal gtest/are_images_equal.cc)
if(WIN32)
target_sources(are_images_equal PRIVATE ${CMAKE_SOURCE_DIR}/apps/utf8.rc)
if(NOT MINGW)
target_link_options(are_images_equal PRIVATE /MANIFEST:NO)
if(MSVC)
target_sources(are_images_equal PRIVATE ${CMAKE_SOURCE_DIR}/apps/utf8.manifest)
elseif(MINGW)
target_sources(are_images_equal PRIVATE ${CMAKE_SOURCE_DIR}/apps/utf8.rc)
endif()
endif()
target_link_libraries(are_images_equal aviftest_helpers avif_enable_warnings)
Expand Down

0 comments on commit 4362ac6

Please sign in to comment.