# Cmake re-run with cuda code

**URL:** https://discourse.cmake.org/t/cmake-re-run-with-cuda-code/2698
**Category:** Usage
**Tags:** os:windows, comp:msvc
**Created:** [February 4, 2021, 1:20pm UTC](https://discourse.cmake.org/t/cmake-re-run-with-cuda-code/2698 "2021-02-04T13:20:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Xin\_Chen](https://discourse.cmake.org/user_avatar/discourse.cmake.org/xin_chen/32/1179_2.png) [@Xin\_Chen](https://discourse.cmake.org/u/Xin_Chen)
#### Post date: [February 4, 2021, 1:20pm UTC](https://discourse.cmake.org/t/cmake-re-run-with-cuda-code/2698/1 "2021-02-04T13:20:55Z")

</div>

I face an issue about cmake on windows.

When I build a c++ library, if it has cuda code, then cmake will multiple time on windows (depend on how many cuda\_add\_library used)

some code snippet: [https://paste.ubuntu.com/p/KGPSBPfqKr/](https://paste.ubuntu.com/p/KGPSBPfqKr/)

I search the google and find [link1](https://stackoverflow.com/questions/42761301/cmake-rerun-due-to-cuda-generated-files) that say it is the expected behavior. But the cmake will not re-run on linux, may be I missed something?

---

<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: [February 4, 2021, 2:56pm UTC](https://discourse.cmake.org/t/cmake-re-run-with-cuda-code/2698/2 "2021-02-04T14:56:17Z")

</div>

`cuda_add_library` sounds like an old `FindCUDA` mechanism. Have you tried using the built-in CUDA support (adding `CUDA` to the top-level `project()` call or using `enable_language(CUDA)`?). I expect that to work far better these days.

Cc: @robert.maynard @brad.king
