

function plumed_preliminary_test(){
# check if the README contains the word GROMACS and if gromacs has been already configured
  grep -q GROMACS README 1>/dev/null 2>/dev/null
}

function plumed_patch_info(){
cat << EOF
PLUMED can be incorporated into gromacs using the standard patching procedure.
Patching must be done in the gromacs root directory  _before_ the cmake command is invoked.

On clusters you may want to patch gromacs using the static version of plumed, in this case
building gromacs can result in multiple errors. One possible solution is to configure gromacs
with these additional options:

cmake -DBUILD_SHARED_LIBS=OFF -DGMX_PREFER_STATIC_LIBS=ON

To enable PLUMED in a gromacs simulation one should use
mdrun with an extra -plumed flag. The flag can be used to
specify the name of the PLUMED input file, e.g.:

gmx mdrun -plumed plumed.dat

For more information on gromacs you should visit http://www.gromacs.org

EOF
}

plumed_before_patch(){
  plumed_patch_info
  
  mv cmake/gmxVersionInfo.cmake cmake/gmxVersionInfo.cmake.preplumed
  awk -v version="$PLUMED_VERSION" '/^set\(GMX_VERSION_STRING_OF_FORK/{gsub(/""/, "plumed-" version)}; {print}' cmake/gmxVersionInfo.cmake.preplumed > cmake/gmxVersionInfo.cmake
}

PLUMED_PREPLUMED_IGNORE=cmake/gmxVersionInfo.cmake

