CMake Configuration Fails with OpenMP_CUDA Not Found
Environment Configuration
| Component | Version |
|---|---|
| GPU Model | NVIDIA RTX 4070 |
| CUDA Toolkit | 12.8 |
| Visual Studio | 2022 (17.9.6) |
| CMake | 3.31.0 |
| OS | Windows 10 |
Reproduction Steps
git clone https://github.com/NVIDIA/cuda-samples
cd cuda-samples
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64
Error LogCMake Error at D:/CMake/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
Could NOT find OpenMP_CUDA (missing: OpenMP_CUDA_FLAGS OpenMP_CUDA_LIB_NAMES)
Call Stack:
FindOpenMP.cmake:616 (find_package_handle_standard_args)
Samples/0_Introduction/UnifiedMemoryStreams/CMakeLists.txt:21 (find_package)
This looks like it might be a CMake issue. Support for the CUDA language in FindOpenMP was added in CMake 3.31 so it's pretty new, there may be fixes needed for Visual Studio.
Thanks for the report, we're looking into it.
For now, if you don't actually need to build that sample, you can comment out the corresponding add_subdirectory command in the CMakeLists.txt in the parent folder
Thanks, the fix works fine, the other 181 sample projects are generated .
CMake: cmake version 4.0.1 cuda-samples\Samples\0_Introduction\UnifiedMemoryStreams\CMakeLists.txt
# Source file
# find_package(OpenMP REQUIRED)
find_package(OpenMP REQUIRED C CXX)
also happened using cmake 4.1.1, arch linux. fixed it changing the file Samples/0_Introduction/UnifiedMemoryStreams/CMakeLists.txt:32 (find_package):
find_package(OpenMP REQUIRED C CXX)
I tried @moraisaugusto suggestion on the previous comment, but that didn't work for me.
What worked for me was simply checking out the tag corresponding to my CUDA version, without modifying any file:
git checkout v12.9
I'm using Manjaro with CUDA 12.9.1 and CMake 4.1.1. My laptop has a NVIDIA RTX 4070 GPU.