Skip to content

[Code scan] Raise or gate the CMake minimum for CUDA and dynamic cudart features #143

Description

@njzjz

This issue was found by a Codex global scan of the repository at commit 19f9265.

The project declares CMake 3.15 as sufficient:

cmake_minimum_required(VERSION 3.15)
project(deepmd-gnn CXX)

The CUDA build path uses newer CMake features, including FindCUDAToolkit, CUDA language/runtime properties, and COMMAND_ERROR_IS_FATAL in the dynamic cudart stub generation path:

if(DEEPMD_GNN_WITH_CUDA STREQUAL "ON")
find_package(CUDAToolkit REQUIRED)
elseif(DEEPMD_GNN_WITH_CUDA STREQUAL "AUTO")
find_package(CUDAToolkit QUIET)

if(NOT DEFINED CMAKE_CUDA_COMPILER)
set(CMAKE_CUDA_COMPILER ${DEEPMD_GNN_NVCC_EXECUTABLE})
endif()
if(NOT DEFINED CMAKE_CUDA_HOST_COMPILER)
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
endif()
enable_language(CUDA)

if(DEEPMD_GNN_ENABLE_CUDA)
target_compile_definitions(deepmd_gnn PRIVATE DEEPMD_GNN_WITH_CUDA)
set_target_properties(deepmd_gnn PROPERTIES CUDA_STANDARD 17)
if(TARGET deepmd_gnn_cudart)
set_target_properties(deepmd_gnn PROPERTIES CUDA_RUNTIME_LIBRARY None)
target_link_libraries(deepmd_gnn PRIVATE deepmd_gnn_cudart ${CMAKE_DL_LIBS})
endif()

execute_process(
COMMAND
${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/third_party/implib/implib-gen.py
${CUDART_LOCATION} --target ${CMAKE_SYSTEM_PROCESSOR} --dlopen-callback
DPGNN_cudart_dlopen --dlsym-callback DPGNN_cudart_dlsym
COMMAND_ERROR_IS_FATAL ANY
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

Users with an accepted-but-too-old CMake can hit confusing configure failures, especially when DEEPMD_GNN_WITH_CUDA=ON or dynamic cudart is enabled.

Suggested fix: raise cmake_minimum_required() to the real minimum needed by the CUDA/dynamic-cudart path, or gate/replace the newer commands for older CMake versions. At minimum, fail early with a clear diagnostic when those paths are requested.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions