Skip to content

Commit d244f9e

Browse files
Copilotnjzjz
andauthored
fix: bump CMake minimum version to 3.25.2 (#5001)
## Summary This PR bumps the CMake minimum required version from 3.16 to 3.25.2 across the repository to support the `RUN_OUTPUT_STDOUT_VARIABLE` option used in `source/cmake/Findtensorflow.cmake`. ## Background PR #4890 introduced the use of `RUN_OUTPUT_STDOUT_VARIABLE` in the `try_run()` command within `source/cmake/Findtensorflow.cmake` (line 297). This CMake feature was added in CMake 3.25, but the minimum required version was still set to 3.16, which would cause build failures on systems with older CMake versions. Additionally, CMake 3.25.0 and 3.25.1 contain a bug (https://gitlab.kitware.com/cmake/cmake/-/issues/24275), so the minimum version is set to 3.25.2 to avoid this issue. ## Changes This PR updates the CMake version requirements consistently across all build configuration files: - **Main CMakeLists.txt**: Updated base requirement and conditional requirements for CUDA/ROCM variants - **Python build configuration** (`backend/read_env.py`): Updated version requirements for CPU, CUDA, and ROCM variants - **Documentation** (`doc/install/install-from-source.md`): Simplified to state that CMake 3.25.2+ is required for all platforms - **Test and example CMakeLists**: Updated all test directories and example projects to require CMake 3.25.2 for consistency ### Files Modified - `source/CMakeLists.txt` - `backend/read_env.py` - `doc/install/install-from-source.md` - `source/lib/src/gpu/CMakeLists.txt` - `source/lib/tests/CMakeLists.txt` - `source/api_c/tests/CMakeLists.txt` - `source/api_cc/tests/CMakeLists.txt` - `source/lmp/plugin/CMakeLists.txt` - `examples/infer_water/CMakeLists.txt` ## Impact Users will need CMake 3.25.2 or later to build DeePMD-kit from source. CMake 3.25.2 was released in March 2022, so it should be widely available. Users can easily install or upgrade CMake via pip: ```bash pip install -U cmake ``` Fixes the issue where builds would fail with CMake versions between 3.16 and 3.24 due to the use of `RUN_OUTPUT_STDOUT_VARIABLE`, and avoids the bug present in CMake 3.25.0 and 3.25.1. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[BUG] CMake minimal version should be bumped to 3.25</issue_title> > <issue_description>### Bug summary > > #4890 uses `RUN_OUTPUT_STDOUT_VARIABLE` which is new in CMake 3.25. Thus, the CMake minimal version should be bumped to 3.25 in CMakeLists.txt, read_env.py, and the documentation. > > ### DeePMD-kit Version > > devel > > ### Backend and its version > > - > > ### How did you download the software? > > Built from source > > ### Input Files, Running Commands, Error Log, etc. > > As above. > > ### Steps to Reproduce > > As above. > > ### Further Information, Files, and Links > > _No response_</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> Fixes #5000 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start the survey. --------- Signed-off-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> Co-authored-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn>
1 parent 54dae2f commit d244f9e

10 files changed

Lines changed: 19 additions & 19 deletions

File tree

backend/read_env.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def get_argument_from_env() -> tuple[str, list, list, dict, str, str]:
4646
# get variant option from the environment variables, available: cpu, cuda, rocm
4747
dp_variant = os.environ.get("DP_VARIANT", "cpu").lower()
4848
if dp_variant == "cpu" or dp_variant == "":
49-
cmake_minimum_required_version = "3.16"
49+
cmake_minimum_required_version = "3.25.2"
5050
elif dp_variant == "cuda":
51-
cmake_minimum_required_version = "3.23"
51+
cmake_minimum_required_version = "3.25.2"
5252
cmake_args.append("-DUSE_CUDA_TOOLKIT:BOOL=TRUE")
5353
cuda_root = os.environ.get("CUDAToolkit_ROOT")
5454
if cuda_root:
5555
cmake_args.append(f"-DCUDAToolkit_ROOT:STRING={cuda_root}")
5656
elif dp_variant == "rocm":
57-
cmake_minimum_required_version = "3.21"
57+
cmake_minimum_required_version = "3.25.2"
5858
cmake_args.append("-DUSE_ROCM_TOOLKIT:BOOL=TRUE")
5959
rocm_root = os.environ.get("ROCM_ROOT")
6060
if not rocm_root:

doc/install/install-from-source.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ mkdir build
377377
cd build
378378
```
379379

380-
The installation requires CMake 3.16 or later for the CPU version, CMake 3.23 or later for the CUDA support, and CMake 3.21 or later for the ROCM support. One can install CMake via `pip` if it is not installed or the installed version does not satisfy the requirement:
380+
The installation requires CMake 3.25.2 or later for all platforms (CPU, CUDA, and ROCM). One can install CMake via `pip` if it is not installed or the installed version does not satisfy the requirement:
381381

382382
```sh
383383
pip install -U cmake

examples/infer_water/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.7)
1+
cmake_minimum_required(VERSION 3.25.2)
22
project(infer_water)
33

44
# find DeePMD-kit

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,8 @@ DP_ENABLE_IPI = "1"
283283
DP_ENABLE_PYTORCH = "1"
284284
DP_ENABLE_PADDLE = "1"
285285
# use CPU version of torch for building, which should also work for GPU
286-
# note: uv has different behavior from pip on extra index url
287-
# https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY.md#packages-that-exist-on-multiple-indexes
288-
UV_EXTRA_INDEX_URL = "https://download.pytorch.org/whl/cpu"
286+
# https://docs.astral.sh/uv/guides/integration/pytorch/#automatic-backend-selection
287+
UV_TORCH_BACKEND = "cpu"
289288

290289
[tool.cibuildwheel.windows]
291290
test-extras = ["cpu", "torch", "paddle"]

source/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# new in 3.16: GET_RUNTIME_DEPENDENCIES, target_precompile_headers
2-
cmake_minimum_required(VERSION 3.16)
1+
# new in 3.25: RUN_OUTPUT_STDOUT_VARIABLE
2+
cmake_minimum_required(VERSION 3.25.2)
33
project(DeePMD)
44

55
option(ENABLE_TENSORFLOW "Enable TensorFlow interface" OFF)
@@ -244,7 +244,7 @@ set(DP_VARIANT "cpu")
244244

245245
# define USE_CUDA_TOOLKIT
246246
if(USE_CUDA_TOOLKIT)
247-
cmake_minimum_required(VERSION 3.23)
247+
cmake_minimum_required(VERSION 3.25.2)
248248
find_package(CUDAToolkit REQUIRED)
249249
if(NOT DEFINED CMAKE_CUDA_COMPILER)
250250
set(CMAKE_CUDA_COMPILER ${CUDAToolkit_NVCC_EXECUTABLE})
@@ -261,7 +261,7 @@ endif(USE_CUDA_TOOLKIT)
261261

262262
# define USE_ROCM_TOOLKIT
263263
if(USE_ROCM_TOOLKIT)
264-
cmake_minimum_required(VERSION 3.21)
264+
cmake_minimum_required(VERSION 3.25.2)
265265
include(CMakeDetermineHIPCompiler)
266266
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_HIP_COMPILER_ROCM_ROOT})
267267
find_package(hip REQUIRED)

source/api_c/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.9)
1+
cmake_minimum_required(VERSION 3.25.2)
22
project(deepmd_api_c_test)
33

44
file(GLOB TEST_SRC test_*.cc)

source/api_cc/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.9)
1+
cmake_minimum_required(VERSION 3.25.2)
22
project(deepmd_api_test)
33

44
file(GLOB TEST_SRC test_*.cc)

source/lib/src/gpu/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
if(USE_CUDA_TOOLKIT)
2-
# required cmake version 3.23: CMAKE_CUDA_ARCHITECTURES all
3-
cmake_minimum_required(VERSION 3.23)
2+
# required cmake version 3.25: CMAKE_CUDA_ARCHITECTURES all,
3+
# RUN_OUTPUT_STDOUT_VARIABLE
4+
cmake_minimum_required(VERSION 3.25.2)
45
# project name
56
project(deepmd_op_cuda)
67
set(GPU_LIB_NAME deepmd_op_cuda)
@@ -54,7 +55,7 @@ if(USE_CUDA_TOOLKIT)
5455
elseif(USE_ROCM_TOOLKIT)
5556

5657
# required cmake version
57-
cmake_minimum_required(VERSION 3.21)
58+
cmake_minimum_required(VERSION 3.25.2)
5859
# project name
5960
project(deepmd_op_rocm)
6061
enable_language(HIP)

source/lib/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.9)
1+
cmake_minimum_required(VERSION 3.25.2)
22
project(libdeepmd_test)
33

44
file(GLOB TEST_SRC test_*.cc)

source/lmp/plugin/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION)
22
message(STATUS "enable LAMMPS plugin mode")
33
add_library(lammps_interface INTERFACE)
44
if(DEFINED LAMMPS_VERSION)
5-
cmake_minimum_required(VERSION 3.14)
5+
cmake_minimum_required(VERSION 3.25.2)
66
include(FetchContent)
77
FetchContent_Declare(
88
lammps_download

0 commit comments

Comments
 (0)