# How to set $PATH for try\_compile runs, and during build?

**URL:** https://discourse.cmake.org/t/how-to-set-path-for-try-compile-runs-and-during-build/10256
**Category:** Usage
**Tags:** os:windows, gen:ninja, lang:cuda
**Created:** [March 1, 2024, 6:13pm UTC](https://discourse.cmake.org/t/how-to-set-path-for-try-compile-runs-and-during-build/10256 "2024-03-01T18:13:28Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![corio](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/d26b3c/32.png) [@corio](https://discourse.cmake.org/u/corio)
#### Post date: [March 11, 2026, 3:53pm UTC](https://discourse.cmake.org/t/how-to-set-path-for-try-compile-runs-and-during-build/10256/5 "2026-03-11T15:53:11Z")

</div>

> [@garyo](#):
>
> I guess the best way on Windows is to open a developer prompt and work from there. That seems to be what cmake is expecting. Oh w

Hi, @garyo

Let me share my experience.  
Originally, I tried to work with Visual Studio Generator and `-T ClangCL` switch but it failed.  
I successfully used WindowsToolchain with cl.exe to build CUDA projects in the past and found it could not use Сlang with Visual Studio Generator or Ninja.

Main reason to run builds on top of Сlang is superior speed of built executables.

Working recipe for standard CUDA samples from Nvidia (it doesn’t require developer prompt, one can open a normal prompt):

```auto
set VS_DIR=c:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools
call “%VS_DIR%\VC\Auxiliary\Build\vcvarsall.bat” x64
set LLVM_DIR=c:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/Llvm/x64
set CUDA_DIR=c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6
set “PATH=%LLVM_DIR%/bin;%CUDA_DIR%/bin;%PATH%”

“c:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe” ^ 
-G Ninja ^
-S “C:/Downloads/cuda-samples-master/cuda-samples-master/Samples/1_Utilities/deviceQuery” ^
-B .^
-DCMAKE_C_COMPILER=“%LLVM_DIR%/bin/clang.exe” ^
-DCMAKE_CXX_COMPILER=“%LLVM_DIR%/bin/clang++.exe” ^
-DCMAKE_CUDA_COMPILER=“C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/bin/nvcc.exe” ^
-DCMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR=“C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6” ^
-DCMAKE_VS_PLATFORM_TOOLSET_CUDA=12.6 ^
-DCUDAToolkit_ROOT=“C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6” ^
-DCMAKE_CUDA_STANDARD=14 ^
-DCMAKE_CUDA_ARCHITECTURES=75 ^
-DCMAKE_CUDA_EXTENSIONS=OFF

```

Hope it helps.

---

_[View the full topic](https://discourse.cmake.org/t/how-to-set-path-for-try-compile-runs-and-during-build/10256)._
