From 9ed039765465229768535dda6d28f60888b2f42d Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 4 Nov 2024 21:46:39 -0500 Subject: [PATCH] fix(cmake): Replace deprecated `FetchContent_Populate` with `FetchContent_MakeAvailable` (#4309) Update `source/lmp/plugin/CMakeLists.txt` to use `FetchContent_MakeAvailable` instead of `FetchContent_Populate`. * Replace `FetchContent_Populate(lammps_download)` with `FetchContent_MakeAvailable(lammps_download)` on line 13. * Remove `FetchContent_GetProperties` and `if(NOT lammps_download_POPULATED)` block. This fixes a CMake warning: ``` CMake Warning (dev) at /home/runner/work/_temp/-111029589/cmake-3.30.5-linux-x86_64/share/cmake-3.30/Modules/FetchContent.cmake:1953 (message): Calling FetchContent_Populate(lammps_download) is deprecated, call FetchContent_MakeAvailable(lammps_download) instead. Policy CMP0169 can be set to OLD to allow FetchContent_Populate(lammps_download) to be called directly for now, but the ability to call it with declared details will be removed completely in a future version. Call Stack (most recent call first): lmp/plugin/CMakeLists.txt:13 (FetchContent_Populate) This warning is for project developers. Use -Wno-dev to suppress it. ``` --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/njzjz/deepmd-kit?shareId=32a460fb-6c67-4397-b000-6f36e9841970). ## Summary by CodeRabbit - **Chores** - Simplified CMake configuration for the LAMMPS plugin, ensuring consistent availability of LAMMPS source. - Streamlined handling of LAMMPS versioning and installation logic. - Updated minimum required CMake version from 3.11 to 3.14. --------- Signed-off-by: Jinzhe Zeng Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- source/lmp/plugin/CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index f912059261..13da3d7114 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -2,17 +2,14 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) message(STATUS "enable LAMMPS plugin mode") add_library(lammps_interface INTERFACE) if(DEFINED LAMMPS_VERSION) - cmake_minimum_required(VERSION 3.11) + cmake_minimum_required(VERSION 3.14) include(FetchContent) FetchContent_Declare( lammps_download GIT_REPOSITORY https://github.com/lammps/lammps GIT_TAG ${LAMMPS_VERSION}) - FetchContent_GetProperties(lammps_download) - if(NOT lammps_download_POPULATED) - FetchContent_Populate(lammps_download) - set(LAMMPS_SOURCE_ROOT ${lammps_download_SOURCE_DIR}) - endif() + FetchContent_MakeAvailable(lammps_download) + set(LAMMPS_SOURCE_ROOT ${lammps_download_SOURCE_DIR}) endif() set(LAMMPS_HEADER_DIR ${LAMMPS_SOURCE_ROOT}/src) message(STATUS "LAMMPS_HEADER_DIR is ${LAMMPS_HEADER_DIR}")