# Cmake Cuda **Repository Path**: denglinAI/cmake-cuda ## Basic Information - **Project Name**: Cmake Cuda - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-27 - **Last Updated**: 2025-11-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README **Now these repo is implemented base on cmake 3.25.3. Additionally, cmake 3.30 has some compatibility bug, please use cmake between cmake 3.25 and cmake 3.29.** ## how to use find_package(CUDA) 1. set dlgpu architecture, you can also add other compiler flags here ``` cmake set(CUDA_NVCC_FLAGS "--cuda-gpu-arch=dlgput64") # other compiler flags set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -DXXX -DYYY") ``` 2. add current repo to `CMAKE_MODULE_PATH`. Additionally, you can use `-DCMAKE_MODULE_PATH="" when typing cmake command ``` cmake list(APPEND CMAKE_MODULE_PATH "") ``` 3. import CUDA module ``` cmake find_package(CUDA REQUIRED) ``` 4. if you want to use separate compilation, set CUDA_SEPARABLE_COMPILATION to ON ``` cmake set(CUDA_SEPARABLE_COMPILATION ON) ``` 5. use cuda_add_executable, cuda_add_library to compile cu files These are examples under `./example/test_find_package` and `./example/test_cuda*` directory, check it to see details. ## how to use enable_language(CUDA) 1. you must set dlgpu architecture first, otherwise there is an error in cmake configure phase ``` cmake set(CMAKE_CUDA_ARCHITECTURES dlgput64) ``` 2. add other compiler flags ``` cmake set(CMAKE_CUDA_FLAGS "-DXXX -DYYY") ``` 3. add current repo to `CMAKE_MODULE_PATH`. Additionally, you can use `-DCMAKE_MODULE_PATH="" when typing cmake command ``` cmake list(APPEND CMAKE_MODULE_PATH "") ``` 4. use CUDA language ``` cmake enable_language(CUDA) ``` 5. use add_executable, add_library to compile cu files These are examples under `./example/test_enable_language*` directory, check it to see details. ## how to execute examples - if you want to execute all examples, just `cd examples` and run `test.sh` - if you want to try single example, you should `cd` corresponding directory, and run commnad blow: ``` cmake cmake -B build -DCMAKE_MODULE_PATH="" ```