# Do I still need FindCUDA ?

**URL:** https://discourse.cmake.org/t/do-i-still-need-findcuda/1705
**Category:** Code
**Tags:** os:linux, lang:cuda
**Created:** [August 14, 2020, 6:35am UTC](https://discourse.cmake.org/t/do-i-still-need-findcuda/1705 "2020-08-14T06:35:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Psykoangel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Psykoangel](https://discourse.cmake.org/u/Psykoangel)
#### Post date: [August 14, 2020, 6:35am UTC](https://discourse.cmake.org/t/do-i-still-need-findcuda/1705/1 "2020-08-14T06:35:57Z")

</div>

Hello CMake Community !

I just had the opportunity to update one of our Ubuntu 20.04 host at work with the last stable CMake snap (actually version 3.18.1) and have been surprised with an error during the build of our project, using Nvidia CUDA, saying that the property CUDA\_ARCHITECTURES was not properly set.  
Okay 🙂, than I looked in the documentation and saw that a new FindCUDAToolkit exists and decided to use it. 🎉  
Except that CMake 3.18.1 doesn’t agree with me and gives me the following error :

```auto
By not providing "FindFindCUDAToolkit.cmake" in CMAKE_MODULE_PATH this   
project has asked CMake to find a package configuration file provided by 
"FindCUDAToolkit", but CMake did not find one.                           
                                                                         
Could not find a package configuration file provided by "FindCUDAToolkit"
with any of the following names:                                         
                                                                         
  FindCUDAToolkitConfig.cmake                                            
  findcudatoolkit-config.cmake                                           

```

Finding this unbelievable, I searched for this .cmake file on the host and found it there :  
`/snap/cmake/513/share/cmake-3.18/Modules/FindCUDAToolkit.cmake`

So, the file exists, but I don’t understand why CMake doesn’t find it. 🤔  
Does it only search for CMake Modules in the project’s root folder and `/usr/lib/x86_64-linux-gnu/cmake/`?  
Do I really need to add the path manually to `CMAKE_MODULE_PATH` or is there a better/proper way to deal with this issue ?

Thanks in advance for your information !  
Best Regards !

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [August 14, 2020, 9:43am UTC](https://discourse.cmake.org/t/do-i-still-need-findcuda/1705/2 "2020-08-14T09:43:12Z")

</div>

You seem to have an additional “Find” prefix in your code

---

<div class="post-metadata">

### Author: ![Psykoangel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Psykoangel](https://discourse.cmake.org/u/Psykoangel)
#### Post date: [August 14, 2020, 9:56am UTC](https://discourse.cmake.org/t/do-i-still-need-findcuda/1705/3 "2020-08-14T09:56:10Z")

</div>

Thanks for the quick answer @hsattler !  
You are incredibly right :  
I declare the following  
`find_package(FindCUDAToolkit REQUIRED)`  
instead of  
`find_package(CUDAToolkit REQUIRED)`  
I did not remember that CMake puts the _Find_ prefix himself for searching for Modules… stupid me 😑  
Thanks a lot !

---

<div class="post-metadata">

### Author: ![jwm](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jwm/32/654_2.png) [@jwm](https://discourse.cmake.org/u/jwm)
#### Post date: [August 14, 2020, 8:51pm UTC](https://discourse.cmake.org/t/do-i-still-need-findcuda/1705/4 "2020-08-14T20:51:31Z")

</div>

But, I would point out that it is obsolete. CUDA is a first-class language now.

```cmake
project( foo
...
         LANGUAGES CXX CUDA
)

```

---

<div class="post-metadata">

### Author: ![Psykoangel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Psykoangel](https://discourse.cmake.org/u/Psykoangel)
#### Post date: [August 17, 2020, 7:08am UTC](https://discourse.cmake.org/t/do-i-still-need-findcuda/1705/5 "2020-08-17T07:08:17Z")

</div>

Thank you for this precision @jwm !  
I didn’t know that and you’re right :  
I removed `find_package(CUDAToolkit REQUIRED)` and replaced

```auto
target_link_libraries(mylib
    CUDA::cudart
    CUDA::cudart_static
)
target_include_directories(mylib
    PUBLIC
        ${CUDAToolkit_INCLUDE_DIRS}
        include
)

```

with

```auto
target_link_libraries(mylib
    cudart
    cudart_static
)
target_include_directories(mylib
    PUBLIC
        ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
        include
)

```

and everything works just fine !  
Thanks for the info, my CMakeLists is much easier now 👍

Regards

---

<div class="post-metadata">

### Author: ![Bai\_Wu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bai_wu/32/4054_2.png) [@Bai\_Wu](https://discourse.cmake.org/u/Bai_Wu)
#### Post date: [December 5, 2023, 6:43am UTC](https://discourse.cmake.org/t/do-i-still-need-findcuda/1705/6 "2023-12-05T06:43:09Z")

</div>

thank you for your info
