22.4.0 fails with "Re-run cmake with a different source directory"

Greetings,

  1. Follow Building 22.4 from Source - Greenbone Community Documentation for ubuntu 22.04
  2. The build fails in the below step:
cmake $SOURCE_DIR/gvmd-$GVMD_VERSION \
  -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
  -DCMAKE_BUILD_TYPE=Release \
  -DLOCALSTATEDIR=/var \
  -DSYSCONFDIR=/etc \
  -DGVM_DATA_DIR=/var \
  -DGVMD_RUN_DIR=/run/gvmd \
  -DOPENVAS_DEFAULT_SOCKET=/run/ospd/ospd-openvas.sock \
  -DGVM_FEED_LOCK_PATH=/var/lib/gvm/feed-update.lock \
  -DSYSTEMD_SERVICE_DIR=/lib/systemd/system \
  -DLOGROTATE_DIR=/etc/logrotate.d \
  -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql

The error is:

CMake Error: The source "/sources/gvmd-22.4.0/CMakeLists.txt" does not match the source "/sources/gvm-libs-22.4.0/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.

A diff of both CMakeLists.txt clearly shows the two files to be totally different right from the start:

$ diff /sources/gvmd-22.4.0/CMakeLists.txt /sources/gvm-libs-22.4.0/CMakeLists.txt
1c1
< # Copyright (C) 2009-2022 Greenbone Networks GmbH
---
> # Copyright (C) 2011-2021 Greenbone Networks GmbH
3c3
< # SPDX-License-Identifier: AGPL-3.0-or-later
---
> # SPDX-License-Identifier: GPL-2.0-or-later
5,8c5,8

Anybody able to build from sources on Ubuntu ? The error does not seem related to a specific version of Ubuntu though.

Thanks in advance,

  • Nestor

Hi Nestor, it seems you did re-use the build directory of gvm-libs for gvmd. Just delete the build dir and re-create it .

1 Like

Thanks bricks. I am trying to add GVM to my own pentest docker and this was my own mistake. For the record I was not setting properly my WORKDIR. A side note we should correct Building 22.4 from Source - Greenbone Community Documentation on the gvmd install to set the PKG_CONFIG_PATH var otherwise it won’t build:

PKG_CONFIG_PATH=$BUILD_DIR/gvm-libs:$PKG_CONFIG_PATH

That should not be necessary if gvm-libs is installed into the default prefix /usr/local/. The pkg-config file can be found in /usr/local/include/pkg-config. If you don’t use the default prefix you shouldn’t point to the build dir and use $PREFIX/include/pkg-config.

1 Like

Indeed. Thanks again bricks. You are absolutely correct.

1 Like

For what is worth bricks, I forgot to say that at least for gvmd and pg-gvm the below command exits with code 1:

cp -rv $INSTALL_DIR/* / 

This means that if scripted the output has to be ignored unless the script is not checking for errors. Docker will definitely stop there unless a hack (like the below) is introduced:

cp -rv $INSTALL_DIR/* / || echo 'cp -rv $INSTALL_DIR/* / returns with exit code 1 but that is not a showstopper apparently'
1 Like

Hi,
I got the same error:
Compiling FibresCalo…

Running cmake command as: cmake …/

CMake Error: The current CMakeCache.txt directory /Users/devanshiarora/downloads/ChromaticCalorimetry/spacal-simulation/build/CMakeCache.txt is different than the directory /home/spacal/Documents/LHCb/simulations/ChromaticCalorimetry/spacal-simulation/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt

CMake Error: The source “/Users/devanshiarora/downloads/ChromaticCalorimetry/spacal-simulation/CMakeLists.txt” does not match the source “/home/spacal/Documents/LHCb/simulations/ChromaticCalorimetry/spacal-simulation/CMakeLists.txt” used to generate cache. Re-run cmake with a different source directory.

Last command “cmake $CMAKE_ARGS …/” returned with exit code 1.