diff options
author | Brad King <brad.king@kitware.com> | 2019-02-26 14:49:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-02-26 14:58:51 (GMT) |
commit | 8375c303e272fd7d20383a86d0c99433b7e0da67 (patch) | |
tree | cd8dc7d38022f4f665938a9ee4f217a126c38e8e /Modules/CMakeDetermineCompilerId.cmake | |
parent | e6897c72e7c59f7a0b82ed19c1bdb40d42f7adaa (diff) | |
download | CMake-8375c303e272fd7d20383a86d0c99433b7e0da67.zip CMake-8375c303e272fd7d20383a86d0c99433b7e0da67.tar.gz CMake-8375c303e272fd7d20383a86d0c99433b7e0da67.tar.bz2 |
VS: Fix detection of clang-cl with -T llvm
When using a VS generator with `-T llvm`, MSBuild relies on the "LLVM
Compiler Toolchain" VS Extension. This does not put `clang-cl` in the
`PATH` inside the build, and LLVM no longer provides a `cl` replacement
either. Therefore we need another way to extract the path to the
`CMAKE_{C,CXX}_COMPILER`. Fortunately the LLVM VS integration provides
a `$(ClangClExecutable)` macro we can reference to get the path.
Fixes: #18983
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 83ce392..4677b40 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -181,7 +181,10 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(vs_version ${CMAKE_MATCH_1}) set(id_platform ${CMAKE_VS_PLATFORM_NAME}) set(id_lang "${lang}") - if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") + set(id_PostBuildEvent_Command "") + if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm]$") + set(id_cl_var "ClangClExecutable") + elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") set(id_cl clang.exe) else() set(id_cl cl.exe) @@ -268,7 +271,11 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) set(id_src "${src}") set(id_compile "ClCompile") - set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i") + if(id_cl_var) + set(id_PostBuildEvent_Command "echo CMAKE_${lang}_COMPILER=$(${id_cl_var})") + else() + set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i") + endif() set(id_Import_props "") set(id_Import_targets "") set(id_ItemDefinitionGroup_entry "") |