You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use environment variables to specify compiler preferences.
The cache variables `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER` must only be set during the initial cache creation. Specifying them in a preset will cause them to be reset during subsequent cache configurations, resulting in a cache invalidation, which can break the build. Using the `CC` and `CXX` environment variables to initialize those cache variables is the proper way to avoid this issue.
Copy file name to clipboardExpand all lines: docs/build/cmake-presets-vs.md
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,29 +205,33 @@ The official [CMake documentation](https://cmake.org/cmake/help/latest/manual/cm
205
205
206
206
### Select your compilers
207
207
208
-
You can set C and C++ compilers by using `cacheVariables.CMAKE_C_COMPILER` and `cacheVariables.CMAKE_CXX_COMPILER` in a Configure Preset. It's equivalent to passing `-D CMAKE_C_COMPILER=<value>` and `-D CMAKE_CXX_COMPILER=<value>` to CMake from the command line. For more information, see [`CMAKE_<LANG>_COMPILER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html#cmake-lang-compiler).
208
+
You can set C and C++ compilers by using `environmentVariables.CC` and `environmentVariables.CXX` in a Configure Preset. For more information, see [`CC`](https://cmake.org/cmake/help/latest/envvar/CC.html)/[`CXX`](https://cmake.org/cmake/help/latest/envvar/CXX.html).
209
209
210
210
Use the following examples to build with `cl.exe` and `clang-cl.exe` from Visual Studio. The C++ Clang tools for Windows components must be installed for you to build with `clang-cl`.
@@ -264,11 +268,13 @@ To reproduce these builds outside Visual Studio, see [Run CMake from the command
264
268
To build on Linux or without the Visual C++ toolset, specify the name of a compiler on your `PATH` instance, or an environment variable that evaluates to the full path of a compiler. Full paths are discouraged so that the file can remain shareable. A preset that builds with GCC version 8 might look like this:
0 commit comments