Skip to content

[CMake]fix CUDAToolkit_LIBRARY_ROOT DEFINED check #146472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

x12301450
Copy link

This PR fixes #146344 by remove the brace of CUDAToolkit_LIBRARY_ROOT.

In mlir/lib/Target/LLVM/CMakeLists.txt, the variable CUDAToolkit_LIBRARY_ROOT is used in the following way in Line 66:

set(MLIR_CUDAToolkit_ROOT ${CUDAToolkit_LIBRARY_ROOT})

and like this in Line 135:

find_file(MLIR_NVVM_LIBDEVICE_PATH libdevice.10.bc
                PATHS ${CUDAToolkit_LIBRARY_ROOT}
                PATH_SUFFIXES "nvvm/libdevice" NO_DEFAULT_PATH REQUIRED)

However, when checking whether the variable is defined, it is done in the following way in Line 62:

if(NOT DEFINED ${CUDAToolkit_LIBRARY_ROOT})

This if command doesn't take effect when CUDAToolkit_LIBRARY_ROOT simply represent a path. I think the correct way to write it should be:

if(NOT DEFINED CUDAToolkit_LIBRARY_ROOT)

Looking forward to your feedback!

Copy link

github-actions bot commented Jul 1, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2025

@llvm/pr-subscribers-mlir-llvm

@llvm/pr-subscribers-mlir

Author: None (x12301450)

Changes

This PR fixes #146344 by remove the brace of CUDAToolkit_LIBRARY_ROOT.

In mlir/lib/Target/LLVM/CMakeLists.txt, the variable CUDAToolkit_LIBRARY_ROOT is used in the following way in Line 66:

set(MLIR_CUDAToolkit_ROOT ${CUDAToolkit_LIBRARY_ROOT})

and like this in Line 135:

find_file(MLIR_NVVM_LIBDEVICE_PATH libdevice.10.bc
                PATHS ${CUDAToolkit_LIBRARY_ROOT}
                PATH_SUFFIXES "nvvm/libdevice" NO_DEFAULT_PATH REQUIRED)

However, when checking whether the variable is defined, it is done in the following way in Line 62:

if(NOT DEFINED ${CUDAToolkit_LIBRARY_ROOT})

This if command doesn't take effect when CUDAToolkit_LIBRARY_ROOT simply represent a path. I think the correct way to write it should be:

if(NOT DEFINED CUDAToolkit_LIBRARY_ROOT)

Looking forward to your feedback!


Full diff: https://github.com/llvm/llvm-project/pull/146472.diff

1 Files Affected:

  • (modified) mlir/lib/Target/LLVM/CMakeLists.txt (+1-1)
diff --git a/mlir/lib/Target/LLVM/CMakeLists.txt b/mlir/lib/Target/LLVM/CMakeLists.txt
index 83fbf7a5fe5f3..7c6fc37c40a83 100644
--- a/mlir/lib/Target/LLVM/CMakeLists.txt
+++ b/mlir/lib/Target/LLVM/CMakeLists.txt
@@ -59,7 +59,7 @@ if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
     # See: https://gitlab.kitware.com/cmake/cmake/-/issues/24858
     # TODO: Bump the MLIR CMake version to 3.26.4 and switch to
     # ${CUDAToolkit_LIBRARY_ROOT}
-    if(NOT DEFINED ${CUDAToolkit_LIBRARY_ROOT})
+    if(NOT DEFINED CUDAToolkit_LIBRARY_ROOT)
       get_filename_component(MLIR_CUDAToolkit_ROOT ${CUDAToolkit_BIN_DIR}
                              DIRECTORY ABSOLUTE)
     else()

@x12301450 x12301450 changed the title fix CUDAToolkit_LIBRARY_ROOT DEFINED check [CMake]fix CUDAToolkit_LIBRARY_ROOT DEFINED check Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]Incorrect usage of variable in CMakeLists.txt
2 participants