# VS generator and toolchain files

**URL:** <https://discourse.cmake.org/t/vs-generator-and-toolchain-files/1177>\
**Category:** Code\
**Tags:** gen:vs\
**Created:** [May 9, 2020, 12:33pm UTC](https://discourse.cmake.org/t/vs-generator-and-toolchain-files/1177 "2020-05-09T12:33:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lectem](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lectem/32/380_2.png) [@Lectem](https://discourse.cmake.org/u/Lectem)\
**Post date:** [May 9, 2020, 12:33pm UTC](https://discourse.cmake.org/t/vs-generator-and-toolchain-files/1177/1 "2020-05-09T12:33:12Z")

</div>

I was trying to use the [Emscripten.cmake](https://github.com/emscripten-core/emscripten/blob/master/cmake/Modules/Platform/Emscripten.cmake) toolchain file with the Visual Studio generator, but it seems it still tries to use `CL.exe` and `LINK.exe`.

Is this a limitation of the generator? It works fine with make and ninja.

(I used the gui to configure)

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [May 11, 2020, 4:36pm UTC](https://discourse.cmake.org/t/vs-generator-and-toolchain-files/1177/2 "2020-05-11T16:36:22Z")

</div>

This might be a limitation? Though VS supports cross-compilation in other ways, so maybe it just has some other mechanism for choosing the Emscripten toolchain. Maybe `cmake -T` offers this?

Cc: @brad.king

---

<div class="post-metadata">

**Author:** ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)\
**Post date:** [May 11, 2020, 5:54pm UTC](https://discourse.cmake.org/t/vs-generator-and-toolchain-files/1177/3 "2020-05-11T17:54:54Z")

</div>

The VS generator produces `.vcxproj` files and uses MSBuild to actually drive the build. The values of `CMAKE_{C,CXX}_COMPILER` are computed automatically from the compiler MSBuild chooses so setting them has no effect. With this generator we can only support toolchains that have integration with MSBuild installed such that one could manually create a project using them through the IDE. Both the Intel C/C++/Fortran compilers and NVIDIA CUDA compilers are examples of this.

For Visual Studio generators the compiler is selected by the [CMAKE\_GENERATOR\_TOOLSET](https://cmake.org/cmake/help/v3.17/variable/CMAKE_GENERATOR_TOOLSET.html#visual-studio-toolset-selection) setting (`cmake -T ...` option). That is something the toolchain file could set, but it will only work if the toolset has proper MSBuild integration.
