diff --git a/CMakeLists.txt b/CMakeLists.txt index 101edcb3b2..664835f2c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) @@ -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") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 732eeaeafa..c77b329452 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)