diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index d42f91f10e..9b42dafc44 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -99,8 +99,15 @@ function(check_for_autogen_files source_dir) endfunction() macro(pkg_depends PKG1 PKG2) - if(PKG_${PKG1} AND NOT (PKG_${PKG2} OR BUILD_${PKG2})) - message(FATAL_ERROR "The ${PKG1} package needs LAMMPS to be built with the ${PKG2} package") + if(DEFINED BUILD_${PKG2}) + if(PKG_${PKG1} AND NOT BUILD_${PKG2}) + message(FATAL_ERROR "The ${PKG1} package needs LAMMPS to be built with -D BUILD_${PKG2}=ON") + endif() + elseif(DEFINED PKG_${PKG2}) + if(PKG_${PKG1} AND NOT PKG_${PKG2}) + message(WARNING "The ${PKG1} package depends on the ${PKG2} package. Enabling it.") + set(PKG_${PKG2} ON CACHE BOOL "" FORCE) + endif() endif() endmacro()