# Enforce arbitrary CudaToolkit version during enable\_language()?

**URL:** https://discourse.cmake.org/t/enforce-arbitrary-cudatoolkit-version-during-enable-language/15256
**Category:** Development
**Created:** [October 20, 2025, 1:59pm UTC](https://discourse.cmake.org/t/enforce-arbitrary-cudatoolkit-version-during-enable-language/15256 "2025-10-20T13:59:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![johe](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/e9c0ed/32.png) [@johe](https://discourse.cmake.org/u/johe)
#### Post date: [October 20, 2025, 1:59pm UTC](https://discourse.cmake.org/t/enforce-arbitrary-cudatoolkit-version-during-enable-language/15256/1 "2025-10-20T13:59:57Z")

</div>

Say I have multiple versions of CUDA installed at e.g.

C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8  
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9

and both versions are on the `PATH`. Can I somehow influence the version that is picked during a `project(… LANGUAGES CUDA)` call or an `enable_langage(CUDA)` call without changing the `PATH` environment variable? By default, always the first version on the path is picked.

As far as I understand variables like `CUDAToolkit_ROOT` and `CMAKE_CUDA_COMPILER` only have an effect if the `PATH` does not contain any `CudaToolkit` entry. Is this correct? Is there a variable I am missing?

What would be the best practice to compile different CUDA programs with different toolkit version?
