diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 8a6f8e3010..0b89c96860 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -12,6 +12,11 @@ endif()
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW)
endif()
+# set policy to silence warnings about requiring execute permission for find_program
+# we use OLD because the python-config script for the Fedora MinGW cross-compiler requires it currently
+if(POLICY CMP0109)
+ cmake_policy(SET CMP0109 OLD)
+endif()
# set policy to silence warnings about timestamps of downloaded files. review occasionally if it may be set to NEW
if(POLICY CMP0135)
cmake_policy(SET CMP0135 OLD)
diff --git a/cmake/Modules/Packages/ML-PACE.cmake b/cmake/Modules/Packages/ML-PACE.cmake
index ce8f02f5f4..84f6f6ea7f 100644
--- a/cmake/Modules/Packages/ML-PACE.cmake
+++ b/cmake/Modules/Packages/ML-PACE.cmake
@@ -1,6 +1,12 @@
-set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2023.10.04.tar.gz" CACHE STRING "URL for PACE evaluator library sources")
+# PACE library support for ML-PACE package
-set(PACELIB_MD5 "70ff79f4e59af175e55d24f3243ad1ff" CACHE STRING "MD5 checksum of PACE evaluator library tarball")
+# set policy to silence warnings about timestamps of downloaded files. review occasionally if it may be set to NEW
+if(POLICY CMP0135)
+ cmake_policy(SET CMP0135 OLD)
+endif()
+
+set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2023.11.25.fix.tar.gz" CACHE STRING "URL for PACE evaluator library sources")
+set(PACELIB_MD5 "b45de9a633f42ed65422567e3ce56f9f" CACHE STRING "MD5 checksum of PACE evaluator library tarball")
mark_as_advanced(PACELIB_URL)
mark_as_advanced(PACELIB_MD5)
GetFallbackURL(PACELIB_URL PACELIB_FALLBACK)
diff --git a/cmake/Modules/Packages/PLUMED.cmake b/cmake/Modules/Packages/PLUMED.cmake
index 4c5a6ddcfe..f53232a2de 100644
--- a/cmake/Modules/Packages/PLUMED.cmake
+++ b/cmake/Modules/Packages/PLUMED.cmake
@@ -1,5 +1,10 @@
# Plumed2 support for PLUMED package
+# set policy to silence warnings about timestamps of downloaded files. review occasionally if it may be set to NEW
+if(POLICY CMP0135)
+ cmake_policy(SET CMP0135 OLD)
+endif()
+
if(BUILD_MPI)
set(PLUMED_CONFIG_MPI "--enable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
@@ -77,6 +82,9 @@ if((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND (CMAKE_CROSSCOMPILING))
DEPENDS plumed_build
COMMENT "Copying Plumed files"
)
+ if(CMAKE_PROJECT_NAME STREQUAL "lammps")
+ target_link_libraries(lammps INTERFACE LAMMPS::PLUMED)
+ endif()
else()
@@ -151,6 +159,9 @@ else()
endif()
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
+ if(CMAKE_PROJECT_NAME STREQUAL "lammps")
+ target_link_libraries(lammps PRIVATE LAMMPS::PLUMED)
+ endif()
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PLUMED REQUIRED plumed)
@@ -165,7 +176,9 @@ else()
endif()
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_LINK_LIBRARIES "${PLUMED_LOAD}")
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_INCLUDE_DIRS}")
+ if(CMAKE_PROJECT_NAME STREQUAL "lammps")
+ target_link_libraries(lammps PUBLIC LAMMPS::PLUMED)
+ endif()
endif()
endif()
-target_link_libraries(lammps PRIVATE LAMMPS::PLUMED)
diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst
index dcbb236a52..a5fe00de17 100644
--- a/doc/src/Build_extras.rst
+++ b/doc/src/Build_extras.rst
@@ -1450,6 +1450,11 @@ in lib/pace or somewhere else, which must be done before building
LAMMPS with this package. The code for the library can be found
at: `https://github.com/ICAMS/lammps-user-pace/ `_
+Instead of including the ML-PACE package directly into LAMMPS, it
+is also possible to skip this step and build the ML-PACE package as
+a plugin using the CMake script files in the ``examples/PACKAGE/pace/plugin``
+folder and then load this plugin at runtime with the :doc:`plugin command `.
+
.. tabs::
.. tab:: CMake build
@@ -1614,6 +1619,11 @@ try a different one, switch to a different build system, consider a
global PLUMED installation or consider downloading PLUMED during the
LAMMPS build.
+Instead of including the PLUMED package directly into LAMMPS, it
+is also possible to skip this step and build the PLUMED package as
+a plugin using the CMake script files in the ``examples/PACKAGE/plumed/plugin``
+folder and then load this plugin at runtime with the :doc:`plugin command `.
+
.. tabs::
.. tab:: CMake build
diff --git a/doc/src/Developer_plugins.rst b/doc/src/Developer_plugins.rst
index dd5431507e..4d822130f3 100644
--- a/doc/src/Developer_plugins.rst
+++ b/doc/src/Developer_plugins.rst
@@ -283,7 +283,7 @@ in the ``examples/kim/plugin`` folder. No changes to the sources of the
KIM package themselves are needed; only the plugin interface and loader
code needs to be added. This example only supports building with CMake,
but is probably a more typical example. To compile you need to run CMake
-with -DLAMMPS_SOURCE_DIR=. Other
+with ``-DLAMMPS_SOURCE_DIR=``. Other
configuration setting are identical to those for compiling LAMMPS.
A second example for a plugin from a package is in the
diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst
index d397638e59..1281d8ead8 100644
--- a/doc/src/Packages_details.rst
+++ b/doc/src/Packages_details.rst
@@ -1797,7 +1797,8 @@ Aidan Thompson^3, Gabor Csanyi^2, Christoph Ortner^4, Ralf Drautz^1.
**Install:**
This package has :ref:`specific installation instructions ` on the
-:doc:`Build extras ` page.
+:doc:`Build extras ` page. This package may also be compiled
+as a plugin to avoid licensing conflicts when distributing binaries.
**Supporting info:**
@@ -2357,7 +2358,9 @@ and Gareth Tribello.
**Install:**
-This package has :ref:`specific installation instructions ` on the :doc:`Build extras ` page.
+This package has :ref:`specific installation instructions ` on the
+:doc:`Build extras ` page. This package may also be compiled
+as a plugin to avoid licensing conflicts when distributing binaries.
**Supporting info:**
diff --git a/examples/PACKAGES/pace/plugin/paceplugin.nsis b/examples/PACKAGES/pace/plugin/paceplugin.nsis
index de8d1d8478..0ca96b95a6 100644
--- a/examples/PACKAGES/pace/plugin/paceplugin.nsis
+++ b/examples/PACKAGES/pace/plugin/paceplugin.nsis
@@ -39,7 +39,7 @@ InstallDir "$LOCALAPPDATA\${PACEPLUGIN}"
ShowInstDetails show
ShowUninstDetails show
-SetCompressor lzma
+SetCompressor zlib
!define MUI_ABORTWARNING
diff --git a/examples/PACKAGES/plumed/plugin/CMakeLists.txt b/examples/PACKAGES/plumed/plugin/CMakeLists.txt
new file mode 100644
index 0000000000..33ed34123d
--- /dev/null
+++ b/examples/PACKAGES/plumed/plugin/CMakeLists.txt
@@ -0,0 +1,59 @@
+# -*- CMake -*- build system for plugin examples.
+# The is meant to be used as a template for plugins that are
+# distributed independent from the LAMMPS package.
+##########################################
+
+cmake_minimum_required(VERSION 3.16)
+
+project(plumedplugin VERSION 1.0 LANGUAGES CXX)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+include(CheckIncludeFileCXX)
+include(LAMMPSInterfacePlugin)
+include(PLUMED)
+
+##########################
+# building the plugins
+
+add_library(plumedplugin MODULE plumedplugin.cpp ${LAMMPS_SOURCE_DIR}/PLUMED/fix_plumed.cpp)
+target_link_libraries(plumedplugin PRIVATE LAMMPS::PLUMED)
+target_link_libraries(plumedplugin PRIVATE lammps)
+target_include_directories(plumedplugin PRIVATE ${LAMMPS_SOURCE_DIR}/PLUMED)
+set_target_properties(plumedplugin PROPERTIES PREFIX "" SUFFIX ".so")
+
+# MacOS seems to need this
+if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ set_target_properties(plumedplugin PROPERTIES LINK_FLAGS "-Wl,-undefined,dynamic_lookup")
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+# tell CMake to export all symbols to a .dll on Windows with special case for MinGW cross-compilers
+ set_target_properties(plumedplugin PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+ if(CMAKE_CROSSCOMPILING)
+ set_target_properties(plumedplugin PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
+ endif()
+
+ get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION)
+ find_program(MAKENSIS_PATH makensis)
+ if(MAKENSIS_PATH)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/lammps.ico
+ ${CMAKE_SOURCE_DIR}/lammps-text-logo-wide.bmp ${CMAKE_SOURCE_DIR}/plumedplugin.nsis
+ ${CMAKE_BINARY_DIR})
+ if(BUILD_MPI)
+ if(USE_MSMPI)
+ add_custom_target(package ${MAKENSIS_PATH} -V1 -DVERSION=${LAMMPS_VERSION}-MSMPI plumedplugin.nsis
+ DEPENDS plumedplugin plumed_copy lammps.ico lammps-text-logo-wide.bmp plumedplugin.nsis
+ BYPRODUCTS LAMMPS-PLUMED-plugin-${LAMMPS_VERSION}-MSMPI.exe)
+ else()
+ add_custom_target(package ${MAKENSIS_PATH} -V1 -DVERSION=${LAMMPS_VERSION}-MPI plumedplugin.nsis
+ DEPENDS plumedplugin plumed_copy lammps.ico lammps-text-logo-wide.bmp plumedplugin.nsis
+ BYPRODUCTS LAMMPS-PLUMED-plugin-${LAMMPS_VERSION}-MPI.exe)
+ endif()
+ else()
+ add_custom_target(package ${MAKENSIS_PATH} -V1 -DVERSION=${LAMMPS_VERSION} plumedplugin.nsis
+ COMMAND ${CMAKE_COMMAND} -E echo ${PWD}
+ DEPENDS plumedplugin plumed_copy lammps.ico lammps-text-logo-wide.bmp plumedplugin.nsis
+ BYPRODUCTS LAMMPS-PLUMED-plugin-${LAMMPS_VERSION}.exe)
+ endif()
+ endif()
+else()
+ set_target_properties(plumedplugin PROPERTIES LINK_FLAGS "-rdynamic")
+endif()
diff --git a/examples/PACKAGES/plumed/plugin/LAMMPSInterfacePlugin.cmake b/examples/PACKAGES/plumed/plugin/LAMMPSInterfacePlugin.cmake
new file mode 120000
index 0000000000..2ac6d20a54
--- /dev/null
+++ b/examples/PACKAGES/plumed/plugin/LAMMPSInterfacePlugin.cmake
@@ -0,0 +1 @@
+../../../../cmake/Modules/LAMMPSInterfacePlugin.cmake
\ No newline at end of file
diff --git a/examples/PACKAGES/plumed/plugin/PLUMED.cmake b/examples/PACKAGES/plumed/plugin/PLUMED.cmake
new file mode 120000
index 0000000000..b69e8b04f5
--- /dev/null
+++ b/examples/PACKAGES/plumed/plugin/PLUMED.cmake
@@ -0,0 +1 @@
+../../../../cmake/Modules/Packages/PLUMED.cmake
\ No newline at end of file
diff --git a/examples/PACKAGES/plumed/plugin/README.txt b/examples/PACKAGES/plumed/plugin/README.txt
new file mode 100644
index 0000000000..2b1971ddbc
--- /dev/null
+++ b/examples/PACKAGES/plumed/plugin/README.txt
@@ -0,0 +1,2 @@
+This folder contains a loader and support files to build the PLUMED package as plugin.
+For more information please see: https://docs.lammps.org/Developer_plugins.html
diff --git a/examples/PACKAGES/plumed/plugin/lammps-text-logo-wide.bmp b/examples/PACKAGES/plumed/plugin/lammps-text-logo-wide.bmp
new file mode 100644
index 0000000000..b9ec4c35f2
Binary files /dev/null and b/examples/PACKAGES/plumed/plugin/lammps-text-logo-wide.bmp differ
diff --git a/examples/PACKAGES/plumed/plugin/lammps.ico b/examples/PACKAGES/plumed/plugin/lammps.ico
new file mode 100644
index 0000000000..cce156bf79
Binary files /dev/null and b/examples/PACKAGES/plumed/plugin/lammps.ico differ
diff --git a/examples/PACKAGES/plumed/plugin/plumedplugin.cpp b/examples/PACKAGES/plumed/plugin/plumedplugin.cpp
new file mode 100644
index 0000000000..48edc48e6e
--- /dev/null
+++ b/examples/PACKAGES/plumed/plugin/plumedplugin.cpp
@@ -0,0 +1,28 @@
+
+#include "lammpsplugin.h"
+#include "version.h"
+
+#include "fix_plumed.h"
+
+using namespace LAMMPS_NS;
+
+static Fix *fix_plumed_creator(LAMMPS *lmp, int argc, char **argv)
+{
+ return new FixPlumed(lmp, argc, argv);
+}
+
+extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
+{
+ lammpsplugin_t plugin;
+ lammpsplugin_regfunc register_plugin = (lammpsplugin_regfunc) regfunc;
+
+ // register plumed fix style
+ plugin.version = LAMMPS_VERSION;
+ plugin.style = "fix";
+ plugin.name = "plumed";
+ plugin.info = "Plumed2 plugin fix style v1.0";
+ plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
+ plugin.creator.v1 = (lammpsplugin_factory1 *) &fix_plumed_creator;
+ plugin.handle = handle;
+ (*register_plugin)(&plugin, lmp);
+}
diff --git a/examples/PACKAGES/plumed/plugin/plumedplugin.nsis b/examples/PACKAGES/plumed/plugin/plumedplugin.nsis
new file mode 100644
index 0000000000..1de9800d26
--- /dev/null
+++ b/examples/PACKAGES/plumed/plugin/plumedplugin.nsis
@@ -0,0 +1,172 @@
+#!Nsis Installer Command Script
+#
+# The following external defines are recognized:
+# ${VERSION} = YYYYMMDD
+
+!include "MUI2.nsh"
+!include "FileFunc.nsh"
+
+!define MUI_ICON "lammps.ico"
+!define MUI_UNICON "lammps.ico"
+!define MUI_HEADERIMAGE
+!define MUI_HEADERIMAGE_BITMAP "lammps-text-logo-wide.bmp"
+!define MUI_HEADERIMAGE_RIGHT
+
+Unicode true
+XPStyle on
+
+!include "LogicLib.nsh"
+!addplugindir "envvar/Plugins/x86-unicode"
+!include "x64.nsh"
+
+RequestExecutionLevel user
+
+!macro VerifyUserIsAdmin
+UserInfo::GetAccountType
+pop $0
+${If} $0 != "admin"
+ messageBox mb_iconstop "Administrator rights required!"
+ setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
+ quit
+${EndIf}
+!macroend
+
+!define PLUMEDPLUGIN "LAMMPS PLUMED Plugin ${VERSION}"
+OutFile "LAMMPS-PLUMED-plugin-${VERSION}.exe"
+
+Name "${PLUMEDPLUGIN}"
+InstallDir "$LOCALAPPDATA\${PLUMEDPLUGIN}"
+
+ShowInstDetails show
+ShowUninstDetails show
+SetCompressor zlib
+
+!define MUI_ABORTWARNING
+
+!insertmacro MUI_PAGE_DIRECTORY
+!insertmacro MUI_PAGE_INSTFILES
+
+!insertmacro MUI_UNPAGE_CONFIRM
+!insertmacro MUI_UNPAGE_INSTFILES
+
+!insertmacro MUI_LANGUAGE "English"
+
+function .onInit
+ # Determine if LAMMPS was already installed and check whether it was in 32-bit
+ # or 64-bit. Then look up path to uninstaller and offer to uninstall or quit
+ SetRegView 32
+ ReadRegDWORD $0 HKCU "Software\LAMMPS-PLUMED" "Bits"
+ SetRegView LastUsed
+ ${If} $0 == "32"
+ SetRegView 32
+ ${ElseIf} $0 == "64"
+ SetRegView 64
+ ${Else}
+ SetRegView 64
+ ${EndIf}
+ ClearErrors
+ ReadRegStr $R0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" "UninstallString"
+ SetRegView LastUsed
+ ${If} ${Errors}
+ DetailPrint "LAMMPS PLUMED plugin not (yet) installed"
+ ${Else}
+ MessageBox MB_YESNO "LAMMPS PLUMED plugin ($0 bit) is already installed. Uninstall existing version?" /SD IDYES IDNO Quit
+ Pop $R1
+ StrCmp $R1 2 Quit +1
+ Exec $R0
+ Quit:
+ Quit
+ ${EndIf}
+ setShellVarContext all
+functionEnd
+
+Section "${PLUMEDPLUGIN}" SecPlumedplugin
+ SectionIn RO
+ # Write LAMMPS installation bitness marker. Always use 32-bit registry view
+ SetRegView 32
+ IntFmt $0 "0x%08X" 64
+ WriteRegDWORD HKCU "Software\LAMMPS-PLUMED" "Bits" $0
+
+ # Switch to "native" registry view
+ SetRegView 64
+ SetShellVarContext current
+
+ SetOutPath "$INSTDIR"
+ CreateDirectory "$INSTDIR\patches"
+ CreateDirectory "$INSTDIR\bin"
+ File lammps.ico
+ File plumedplugin.so
+
+ SetOutPath "$INSTDIR\bin"
+ File plumed.exe
+
+ # Register Application and its uninstaller
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "DisplayName" "${PLUMEDPLUGIN}"
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "Publisher" "The LAMMPS and PLUMED Developers"
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "URLInfoAbout" "lammps.org"
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "DisplayIcon" "$INSTDIR\lammps.ico"
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "DisplayVersion" "${VERSION}"
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "InstallLocation" "$INSTDIR"
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
+
+ ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
+ IntFmt $0 "0x%08X" $0
+ WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED" \
+ "EstimatedSize" "$0"
+
+ # update path variables
+ EnVar::SetHKCU
+ # add plumed executable path
+ EnVar::AddValue "PATH" "$INSTDIR\bin"
+ # add to LAMMPS plugin search path
+ EnVar::AddValue "LAMMPS_PLUGIN_PATH" "$INSTDIR"
+ # add plumed2 patch files
+ EnVar::AddValue "PLUMED_ROOT" "$INSTDIR"
+
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+SectionEnd
+
+function un.onInit
+ SetShellVarContext current
+functionEnd
+
+Section "Uninstall"
+ # remove LAMMPS bitness/installation indicator always in 32-bit registry view
+ SetRegView 32
+ DeleteRegKey HKCU "Software\LAMMPS-PLUMED"
+
+ # unregister extension, and uninstall info
+ SetRegView 64
+ SetShellVarContext current
+ # unregister installation
+ DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LAMMPS-PLUMED"
+
+ # update path variables
+ EnVar::SetHKCU
+ # remove plumed executable path
+ EnVar::DeleteValue "PATH" "$INSTDIR\bin"
+ # remove entry from LAMMPS plugin search path
+ EnVar::DeleteValue "LAMMPS_PLUGIN_PATH" "$INSTDIR"
+ # remove plumed patch environment
+ EnVar::Delete "PLUMED_ROOT"
+
+ RMDir /r /REBOOTOK "$INSTDIR\patches"
+ RMDir /r /REBOOTOK "$INSTDIR\bin"
+ Delete /REBOOTOK "$INSTDIR\plumedplugin.so"
+ Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
+ Delete /REBOOTOK "$INSTDIR\lammps.ico"
+ RMDir /REBOOTOK "$INSTDIR"
+SectionEnd
+
+# Local Variables:
+# mode: sh
+# End: