# Is it exlicitly described in the doc that Modern CMake will only compile \`.cu\` files with \`nvcc\`?

**URL:** https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954
**Category:** Code
**Tags:** lang:cuda
**Created:** [November 25, 2022, 12:51pm UTC](https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954 "2022-11-25T12:51:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![songyuc](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a698b9/32.png) [@songyuc](https://discourse.cmake.org/u/songyuc)
#### Post date: [November 25, 2022, 12:51pm UTC](https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954/1 "2022-11-25T12:51:33Z")

</div>

Hi, guys,  
I am a learner of CMake, and I find that CMake would only compile `.cu` files with `nvcc`, except any files with the other extensions.  
Is this rule exlicitly described in the CMake documentation?  
Currently, I have not been able to find relevant content.

Your answer and sharing will be appreciated!

---

<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: [November 30, 2022, 7:36pm UTC](https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954/2 "2022-11-30T19:36:22Z")

</div>

@robert.maynard

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [November 30, 2022, 9:41pm UTC](https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954/3 "2022-11-30T21:41:18Z")

</div>

`.cu` files by default are mapped to the CUDA language. CMake supports compiling CUDA sources with either `nvcc` and `clang` which is documented at: [https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html](https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html)

If you want to compile a `.cu` file as a C++ source you would set the `LANGUAGE` source file property to `CXX`.

---

<div class="post-metadata">

### Author: ![songyuc](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a698b9/32.png) [@songyuc](https://discourse.cmake.org/u/songyuc)
#### Post date: [December 2, 2022, 12:21pm UTC](https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954/4 "2022-12-02T12:21:05Z")

</div>

Thanks sincerely for your guidance!
