NVIDIA / NVIDIA/CUDALibrarySamples
cuFFT samples contain bad CMake code
@mferreravila is already working on this.
Since Jun 27, 2025.
- Dominant language
- Cuda
- Stars
- 2.5k
- Forks
- 478
- PR merge metrics
- No merged PRs in 30d
Description
The lines
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_CUDA_ARCHITECTURES LESS 60)
set(CMAKE_CUDA_ARCHITECTURES 60 70 75 80 86)
endif()
are useless. Configuring with just cmake (no arguments) leaves CMAKE_BUILD_TYPE blank and sets CMAKE_CUDA_ARCHITECTURES to 52.
CMAKE_CUDA_ARCHITECTURE does not matter at all for these builds as CMake will by default compile and link .cpp files using the host compiler (e.g. g++). In fact one can (should?) remove CUDA from the project() command without changing the result. Similarly the blank CMAKE_BUILD_TYPE still results in -O3 -DNDEBUG being used for compilation. So there isn't really a good reason for this code in the first place.
Explicitly putting ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} into target_include_directories() seems uninformed as well as this should happen automatically through the linked targets (e.g. CUDA::cufft includes information about its header location).
One might also argue that the general CMake style could be improved by avoiding most uses of set() and using the modern target APIs for e.g. properties and compile features, but that is another matter.
I generally like the inclusion of CMakeLists.txt in this repository. But they are arguably as important to reflect best practices as the source code because novices will learn from them and reuse/adapt them in many places.
These code snippets are already finding their way into the wild (e.g. StackOverflow) causing headaches to CMake novices.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.