Skip to content

Cmake build system breaks with symbolic links #31145

@laanwj

Description

@laanwj

If the build directory is a symbolic link, or when the entire source directory is symlinked (and we build from there), the current cmake build runs into trouble finding its own generated files.

To reproduce:

git clone --depth=1 https://github.com/bitcoin/bitcoin.git
mkdir build
cd bitcoin/
ln -s ../build .
cmake -Bbuild -DBUILD_GUI=ON
cd build
make
[ 37%] Building CXX object src/CMakeFiles/bitcoin_node.dir/validation.cpp.o
In file included from /data/src/tmp/bitcoin/build/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:2:
/data/src/tmp/bitcoin/build/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_addressbookpage.cpp:10:10: fatal error: ../../../../../src/qt/addressbookpage.h: No such file or directory
   10 | #include "../../../../../src/qt/addressbookpage.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/qt/CMakeFiles/bitcoinqt.dir/build.make:784: src/qt/CMakeFiles/bitcoinqt.dir/bitcoinqt_autogen/mocs_compilation.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs...

This affects the build with Qt as well as the build with multiprocess, both which have generated files.

With autotools this wasn't an issue, so i think it can be considered a regression. But not a high-priority one as it can be worked around by specifying the full paths instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions