You are not using CMake correctly. There is a detailed Howto about using CMake with LAMMPS in the manual and there are plenty of explanations. What you are doing is (obviously) incorrect and in contradiction to the explanations of the manual.
If you need more information about using CMake itself, then - of course - you need to also study the CMake documentation. There is no point in including a detailed CMake tutorial in the LAMMPS documentation, same as we don’t include tutorials for using a compiler or programming in C++ or similar.