WindowsStore & VS Generator strange errors in Compiler Test with /WINMD
So I am trying to switch the generator used in uwp triplets in vcpkg from the VS Generators to mostly Ninja using the toolchain here: https://github.com/microsoft/vcpkg/blob/a9ae1efd9665f4f9f8b4401ece0ee4be35f73a1e/scripts/toolchains/uwp.cmake
More than 800 ports build fine with that toolchain but some of them fail with a strange error in the compiler test and I don't know why this might be happening (after further testing it is becasue those ports are using the VS Generator instead of ninja). The error is:
CMake Error at G:/vcpkg_common/downloads/tools/cmake-3.22.2-windows/cmake-3.22.2-windows-i386/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: E:/vcpkg_folders/master/buildtrees/sltbench/x64-uwp-rel/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_04d7d.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R)-Build-Engine, Version 17.1.0+ae57d105c für .NET Framework
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
testCCompiler.c
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [E:\vcpkg_folders\master\buildtrees\sltbench\x64-uwp-rel\CMakeFiles\CMakeTmp\cmTC_04d7d.vcxproj]
cmTC_04d7d.vcxproj -> E:\vcpkg_folders\master\buildtrees\sltbench\x64-uwp-rel\CMakeFiles\CMakeTmp\Debug\cmTC_04d7d.exe
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.AppXPackage.Targets(2720,5): warning : Der Herausgebername (CN=CMake) stimmt nicht mit dem Signaturzertifikataussteller überein: CN=CMake Test Cert. Der Herausgebername wird aktualisiert. [E:\vcpkg_folders\master\buildtrees\sltbench\x64-uwp-rel\CMakeFiles\CMakeTmp\cmTC_04d7d.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.AppXPackage.Targets(2991,5): error APPX0702: Die Nutzdatendatei "E:\vcpkg_folders\master\buildtrees\sltbench\x64-uwp-rel\CMakeFiles\CMakeTmp\Debug\cmTC_04d7d.winmd" ist nicht vorhanden. [E:\vcpkg_folders\master\buildtrees\sltbench\x64-uwp-rel\CMakeFiles\CMakeTmp\cmTC_04d7d.vcxproj]
After testing the compiler test chokes on /WINMD
in CMAKE_EXE_LINKER_FLAGS
for Visual Studio Generators.
I also observed that I have problems to pass the /FU flag correctly because it contains spaces
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" _vcpkg_vctools)
set(ENV{_CL_} "/FU\"${_vcpkg_vctools}/lib/x86/store/references/platform.winmd\" $ENV{_CL_}")
# CMake has problems to correctly pass this in the compiler test so probably need special care in `vcpkg_get_cmake_vars`
#set(_vcpkg_winmd_flag "/FU\\\\\"${_vcpkg_vctools}/lib/x86/store/references/platform.winmd\\\\\"") # VS normally passes /ZW for Apps (gets added by cmake)
set(CMAKE_CXX_FLAGS "${_vcpkg_cpp_flags} ${_vcpkg_common_flags} ${_vcpkg_winmd_flag} ${_vcpkg_charset} ${VCPKG_CXX_FLAGS}" CACHE STRING "")
set(CMAKE_C_FLAGS "${_vcpkg_cpp_flags} ${_vcpkg_common_flags} ${_vcpkg_winmd_flag} ${_vcpkg_charset} ${VCPKG_C_FLAGS}" CACHE STRING "")