[PR #437] Fix unknown CMake command "cuda_add_library" in CMakeLists.txt #446

Open
opened 2026-10-26 21:17:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/437
Author: @PerryLink
Created: 9/10/2026
Status: 🔄 Open

Base: main ← Head: fix/undefined-cuda-add-library


📝 Commits (1)

  • b4dd001 Fix unknown CMake command "cuda_add_library" in CMakeLists.txt

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 CMakeLists.txt (+1 -1)

📄 Description

CMakeLists.txt cannot configure: line 32 (nv_dev) / line 34 (main) calls cuda_add_library(), which is a macro from the deprecated FindCUDA module — but the file never loads that module; it only calls find_package(CUDAToolkit) on line 16. CMake aborts with:

Unknown CMake command "cuda_add_library".

That is fatal at configure time, so the CLion indexing support this file was added for has never worked — cuda_add_library is present in the file as far back as 5bda2724 ("Add CMake support for CLion indexing"), and find_package(CUDA) appears in no revision of it.

Reproduction

On CMake 4.4.3 a reduced case is enough — no CUDA toolkit and no torch required:

cmake_minimum_required(VERSION 3.18)
project(repro LANGUAGES CXX)
find_package(CUDAToolkit QUIET)   # line 16's call; does not define cuda_add_library
cuda_add_library(t STATIC repro.cpp)
CMake Error at CMakeLists.txt:4 (cuda_add_library):
  Unknown CMake command "cuda_add_library".

Root cause

FindCUDA defines the command only after find_package(CUDA), which appears in no revision of this file:

after find_package(CUDAToolkit): cuda_add_library is NOT DEFINED
after find_package(CUDA):        cuda_add_library IS DEFINED

The rest of the file is already on the modern path (project(... LANGUAGES CXX CUDA) line 3, CMAKE_CUDA_STANDARD line 22, find_package(CUDAToolkit) line 16), so FindCUDA is simply never pulled in.

Fix

-cuda_add_library(deep_gemm_indexing_cuda STATIC csrc/indexing/main.cu)
+add_library(deep_gemm_indexing_cuda STATIC csrc/indexing/main.cu)

Plain add_library() is the right form: CUDA is already listed in project(... LANGUAGES ...), so the .cu source still goes through nvcc without FindCUDA.

I deliberately did not add find_package(CUDA). FindCUDA has been deprecated since CMake 3.10, and with CMP0146 set to NEW (or once cmake_minimum_required reaches 3.27) find_package(CUDA) defines nothing and the error comes straight back:

after find_package(CUDA), CMP0146=NEW: cuda_add_library is NOT DEFINED

It would also contradict the CUDAToolkit usage on line 16.

Verification

Same reduced case with the one-line change:

-- Configuring done (6.1s)
-- Generating done (0.2s)

Note

Lines 7-10 (CUDA_SEPARABLE_COMPILATION, CUDA_NVCC_FLAGS) are FindCUDA variables too and are currently no-ops for the same reason. I left them out to keep this to one line — happy to send that as a separate PR if you want it.

Base branch

Targeting main (the default branch). nv_dev carries the same broken line but is 108 commits ahead of main, so this one-line change was rebased onto main rather than moved across; the identical change applies to nv_dev if you would rather take it there.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/DeepGEMM/pull/437 **Author:** [@PerryLink](https://github.com/PerryLink) **Created:** 9/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/undefined-cuda-add-library` --- ### 📝 Commits (1) - [`b4dd001`](https://github.com/deepseek-ai/DeepGEMM/commit/b4dd00122007e52fe32870930d951f8f59b5fde6) Fix unknown CMake command "cuda_add_library" in CMakeLists.txt ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+1 -1) </details> ### 📄 Description `CMakeLists.txt` cannot configure: line 32 (nv_dev) / line 34 (main) calls `cuda_add_library()`, which is a macro from the deprecated `FindCUDA` module — but the file never loads that module; it only calls `find_package(CUDAToolkit)` on line 16. CMake aborts with: ``` Unknown CMake command "cuda_add_library". ``` That is fatal at configure time, so the CLion indexing support this file was added for has never worked — `cuda_add_library` is present in the file as far back as `5bda2724` ("Add CMake support for CLion indexing"), and `find_package(CUDA)` appears in no revision of it. ### Reproduction On CMake 4.4.3 a reduced case is enough — no CUDA toolkit and no torch required: ```cmake cmake_minimum_required(VERSION 3.18) project(repro LANGUAGES CXX) find_package(CUDAToolkit QUIET) # line 16's call; does not define cuda_add_library cuda_add_library(t STATIC repro.cpp) ``` ``` CMake Error at CMakeLists.txt:4 (cuda_add_library): Unknown CMake command "cuda_add_library". ``` ### Root cause `FindCUDA` defines the command only after `find_package(CUDA)`, which appears in no revision of this file: ``` after find_package(CUDAToolkit): cuda_add_library is NOT DEFINED after find_package(CUDA): cuda_add_library IS DEFINED ``` The rest of the file is already on the modern path (`project(... LANGUAGES CXX CUDA)` line 3, `CMAKE_CUDA_STANDARD` line 22, `find_package(CUDAToolkit)` line 16), so `FindCUDA` is simply never pulled in. ### Fix ```diff -cuda_add_library(deep_gemm_indexing_cuda STATIC csrc/indexing/main.cu) +add_library(deep_gemm_indexing_cuda STATIC csrc/indexing/main.cu) ``` Plain `add_library()` is the right form: `CUDA` is already listed in `project(... LANGUAGES ...)`, so the `.cu` source still goes through nvcc without `FindCUDA`. I deliberately did not add `find_package(CUDA)`. `FindCUDA` has been deprecated since CMake 3.10, and with `CMP0146` set to `NEW` (or once `cmake_minimum_required` reaches 3.27) `find_package(CUDA)` defines nothing and the error comes straight back: ``` after find_package(CUDA), CMP0146=NEW: cuda_add_library is NOT DEFINED ``` It would also contradict the `CUDAToolkit` usage on line 16. ### Verification Same reduced case with the one-line change: ``` -- Configuring done (6.1s) -- Generating done (0.2s) ``` ### Note Lines 7-10 (`CUDA_SEPARABLE_COMPILATION`, `CUDA_NVCC_FLAGS`) are `FindCUDA` variables too and are currently no-ops for the same reason. I left them out to keep this to one line — happy to send that as a separate PR if you want it. ### Base branch Targeting `main` (the default branch). `nv_dev` carries the same broken line but is 108 commits ahead of `main`, so this one-line change was rebased onto `main` rather than moved across; the identical change applies to `nv_dev` if you would rather take it there. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepGEMM#446
No description provided.