Skip to content

Commit

Permalink
fix(cmake): Replace deprecated FetchContent_Populate with `FetchCon…
Browse files Browse the repository at this point in the history
…tent_MakeAvailable` (deepmodeling#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).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## 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.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Nov 5, 2024
1 parent 4b73fbe commit 9ed0397
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions source/lmp/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit 9ed0397

Please sign in to comment.