CMake/Tests/MSManifest/Subdir/CMakeLists.txt
Andrew Ng 0b552eb877 MSVC: Embed manifests directly for non-incremental vs_link_exe links
This avoids the need to separately execute `mt.exe` to perform the
embedding of manifests into the output for non-incremental links. The
primary motivation for this change is that this separate execution of
`mt.exe` to embed manifests is known to cause intermittent failures due
to AV/security scanning.

The only change in behavior is that any linker generated manifest will
no longer be output as a separate manifest file alongside the output
file.

Fixes: #24531
2023-02-23 14:35:08 -05:00

20 lines
975 B
CMake

configure_file(test.manifest.in test.manifest)
add_executable(MSManifest main.c ${CMAKE_CURRENT_BINARY_DIR}/test.manifest)
if(MSVC AND NOT MSVC_VERSION LESS 1400)
add_test(NAME MSManifest.Single COMMAND
${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:MSManifest>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake)
add_executable(MSManifestNonIncremental main.c ${CMAKE_CURRENT_BINARY_DIR}/test.manifest)
set_property(TARGET MSManifestNonIncremental PROPERTY LINK_FLAGS "/INCREMENTAL:NO")
add_test(NAME MSManifest.Single.NonIncremental COMMAND
${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:MSManifestNonIncremental>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake)
add_executable(MSManifestNone main.c)
set_property(TARGET MSManifestNone PROPERTY LINK_FLAGS "/MANIFEST:NO")
elseif(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang")
add_test(NAME MSManifest.Single COMMAND
${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:MSManifest>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake)
endif()