How to use custom Clang build with VS generator

Is there a way to fully use a custom installation of Clang with the VS generator (2022 in my case) in CMake?

I have a custom build & installation of Clang. Based on MS information on using custom Clang in VS, I was able to do the following:

  1. Use CMake GUI to generate a VS 2022 solution using LLVM-Clang toolset. I do this by passing ClangCL as the -T argument. I use “Specify native compilers” and give paths to my custom clang-cl for C and CXX. Even so, the configure step reports:

    “The CXX compiler identification is Clang 15.0.1 with MSVC-like command-line”

    i.e. it has found the Clang supplied with VS.

  2. As part of my CMake process, write a Directory.build.props file into the binary dir, pointing to my custom Clang installation (per information from the MS help article linked above).

  3. When building the generated solution in VS, I have confirmed that my custom Clang is used.

This works fine for my current use case, but I don’t quite like the fact that CMake’s compiler-detection finds a different compiler (the VS-provided Clang) from the one my build is using (my custom Clang). I wouldn’t want to be tripped up by this futher down the line.

Is there a way to point CMake’s compiler detection to my custom Clang for the VS generator?