# How to use custom Clang build with VS generator

**URL:** https://discourse.cmake.org/t/how-to-use-custom-clang-build-with-vs-generator/13158
**Category:** Usage
**Tags:** os:windows, comp:clang, gen:vs
**Created:** [December 9, 2024, 10:49am UTC](https://discourse.cmake.org/t/how-to-use-custom-clang-build-with-vs-generator/13158 "2024-12-09T10:49:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [December 9, 2024, 10:49am UTC](https://discourse.cmake.org/t/how-to-use-custom-clang-build-with-vs-generator/13158/1 "2024-12-09T10:49:07Z")

</div>

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](https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170#custom_llvm_location), 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:

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?
