When building gromacs with CP2K support, Gromacs is statically linked with the libcp2k.a library, such that it is able to call into cp2k code for the QM part of the simulation.
However, libcp2k in turn depends on other libraries to work, like BLAS or libxc. The CP2K_LINKER_FLAGS CMake variable must be set to the linker flags (ie, linker command line arguments) that allow linking with these libraries.
When you compiled cp2k, you specified an ARCH argument to make (e.g
make -j4 ARCH=Linux-x86-64-gfortran), corresponding to an file in the
arch directory of the cp2k source distribution (for instance
arch/Linux-x86-64-gfortran-generic.ssmp). Open this file, and look for the content of the LDFLAGS and LIBS variable, and put it space separated into the CP2K_LINKER_FLAGS variable. You might have to manually resolve or modify the values: for instance change ‘$(FFTW_LIB)/libfftw3.a’ into
/usr/lib64/libfftw3.a (or elsewhere depending on your fftw installation location)
This also might require some trial and error: if the linker flags are incorrect, you can expect either cmake failing, or the build step failing due to undefined symbols. Googling the undefined symbol name (after possibly demangling it) will indicate which library is missing.