Additional clang link path are not passed to linker
CLang on windows path additional path with clang-specific libraries to linker, that are required for code-coverage build and some other extended features. CMake when use ninja generator does not path this variables to linker. It results in problems when used inside VS Build tools. See details in https://developercommunity.visualstudio.com/t/Clang-libs-not-found-in-BuildTools/10015790?port=1026&fsid=3765040a-6cbc-4e96-b2b2-2b38900e2a36&entry=myfeedback&ref=native&refTime=1650147659510&refUserId=c82b9ed9-5796-6649-bac0-a73c434b9382
Details:
C:\VSExclude\helloworld>clang-cl -v hello.obj
clang version 13.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\x64\bin
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.31.31103\\bin\\Hostx64\\x64\\link.exe" -out:hello.exe "-libpath:C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\Llvm\\x64\\lib\\clang\\13.0.0\\lib\\windows" -nologo hello.obj
Please, take a notice that clang passed C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\x64\lib\clang\13.0.0\lib\windows
as libpath to linker. This path will not be passed with cmake / ninja build. So, build that use add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
compiler switch will fail with clang-cl though cmake.
Additional notice: It will work correctly on Professional version of Visual Studio, as it installs required libraries into C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\lib\x64\
, but will fail with Visual Studio Build Tools