# FindCUDA: CUDA\_HOST\_COMPILER has an invalid default value?

**URL:** https://discourse.cmake.org/t/findcuda-cuda-host-compiler-has-an-invalid-default-value/13326
**Category:** Development
**Created:** [January 3, 2025, 11:12am UTC](https://discourse.cmake.org/t/findcuda-cuda-host-compiler-has-an-invalid-default-value/13326 "2025-01-03T11:12:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hjjvandam](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/c37758/32.png) [@hjjvandam](https://discourse.cmake.org/u/hjjvandam)
#### Post date: [January 3, 2025, 11:12am UTC](https://discourse.cmake.org/t/findcuda-cuda-host-compiler-has-an-invalid-default-value/13326/1 "2025-01-03T11:12:57Z")

</div>

I am having build problems with LAMMPS that go back FindCUDA.cmake. FindCUDA.cmake selects CMAKE\_C\_COMPILER as the default value for the CUDA\_HOST\_COMPILER setting. As CUDA is a version of C++ (see [https://docs.nvidia.com/cuda/pdf/CUDA\_C\_Programming\_Guide.pdf](https://docs.nvidia.com/cuda/pdf/CUDA_C_Programming_Guide.pdf) sections 6.1, 6.1.5, and chapter 17) this choice is invalid (just like the nvcc error messages tell me). In fact if CUDAHOSTCXX is set then this value is used, clearly indicating that it is known that CUDA\_HOST\_COMPILER is supposed to be a C++ compiler and not a C compiler.

Would it not be better to set CUDA\_HOST\_COMPILER to CMAKE\_CXX\_COMPILER by default rather than choosing a default that breaks builds?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 5, 2025, 9:19pm UTC](https://discourse.cmake.org/t/findcuda-cuda-host-compiler-has-an-invalid-default-value/13326/2 "2025-01-05T21:19:26Z")

</div>

The `FindCUDA` module was deprecated long ago, and in fact was removed with a policy in CMake 3.27. Use CMake’s built-in CUDA support instead by adding `CUDA` as a language to enable in the first call to `project()`, or by calling `enable_language()`.
