[CMake] cmake not always replacing symlinks in the path used to access a build.dir?!

René J.V. Bertin rjvbertin at gmail.com
Mon Sep 18 04:48:21 EDT 2017


Hi,

I'm seeing a weird issue with a large project: KDevelop. It was reorganised recently but I think that's what exposes the issue, rather than causing it.
My workflow puts both source and out-of-source build directories rather deep in a dedicated "playground"; for convenience I create symlinks to the parent of both directories in one of my own work directories under my $HOME:

%> ls -l kdevd-lnx-work
lrwxrwxrwx 1 bertin bertin 92 Sep  5 15:18 kdevld-lnx-work -> /opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work

As long as I chdir directly into that "hidden" build.dir, invoke cmake and then make from there things are fine. Problems occur though when I change something in one of the project's CMakeLists.txt files, chdir into the build.dir via the symlink and then issue a make without running cmake by hand.

Consider the example below where I tried to do partial rebuild (something that's always worked reliably for me, a feature I really appreciate with cmake!). Evidently make is being executed in the actual directory, as shown by the output from `pwd` just underneath the `CD` line. Somewhere during the snipped part (which I don't have anymore) cmake was called automatically 	and that's where the symlink must have found its way into the 
Notice how the failing build of iplugin.cpp uses search paths that include the link that don't work with the relative include paths generated by the moc compiler. 

How can happen, for all I can tell cmake has no way of knowing about the symlink?!
FWIW, it's not something I can reproduce easily.

%> where CD
CD is aliased to (cd  !:^ ; !:2*)
%> CD kdevld-lnx-work/build/plugins/ wmake
### now in /opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work/build/plugins
### make -w
### Sun Sep 17 20:32:06 CEST 2017
make: Entering directory `/opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work/build/plugins'
<SNIP>
[  0%] Building CXX object kdevplatform/interfaces/CMakeFiles/KDevPlatformInterfaces.dir/iplugin.cpp.o
cd /home/bertin/work/src/Scratch/KDE/KF5/kdevld-lnx-work/build/kdevplatform/interfaces && /opt/local/bin/ccache /opt/local/bin/clang++-mp-4.0  -DKCOREADDONS_LIB -DKDevPlatformInterfaces_EXPORTS -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050500 -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING -DQT_STRICT_ITERATORS -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -DQT_XML_LIB -DTRANSLATION_DOMAIN=\"kdevplatform\" -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/home/bertin/work/src/Scratch/KDE/KF5/kdevld-lnx-work/build/kdevplatform/interfaces -I/opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work/kf5-kdevelop-5/kdevplatform/interfaces -I/home/bertin/work/src/Scratch/KDE/KF5/kdevld-lnx-work/build/kdevplatform/interfaces/KDevPlatformInterfaces_autogen/include -I/opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work/kf5-kdevelop-5 -I/home/bertin/work/src/Scratch/KDE/KF5/kdevld-lnx-work/build -I/opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work/kf5-kdevelop-5/kdevplatform -I/home/bertin/work/src/Scratch/KDE/KF5/kdevld-lnx-work/build/kdevplatform -isystem /opt/local/include/KF5/KParts -isystem /opt/local/include/KF5 -isystem /opt/local/include/KF5/KIOWidgets -isystem /opt/local/include/KF5/KIOCore -isystem /opt/local/include/KF5/KCoreAddons -isystem /opt/local/include/qt5 -isystem /opt/local/include/qt5/QtCore -isystem /opt/local/share/qt5/mkspecs/linux-g++-64 -isystem /opt/local/include/KF5/KService -isystem /opt/local/include/KF5/KConfigCore -isystem /opt/local/include/KF5/KJobWidgets -isystem /opt/local/include/qt5/QtWidgets -isystem /opt/local/include/qt5/QtGui -isystem /opt/local/include/qt5/QtNetwork -isystem /opt/local/include/KF5/KCompletion -isystem /opt/local/include/KF5/KWidgetsAddons -isystem /opt/local/include/KF5/KXmlGui -isystem /opt/local/include/qt5/QtDBus -isystem /opt/local/include/qt5/QtXml -isystem /opt/local/include/KF5/KConfigWidgets -isystem /opt/local/include/KF5/KCodecs -isystem /opt/local/include/KF5/KConfigGui -isystem /opt/local/include/KF5/KAuth -isystem /opt/local/include/KF5/KTextWidgets -isystem /opt/local/include/KF5/SonnetUi -isystem /opt/local/include/KF5/KI18n -isystem /opt/local/include/KF5/KTextEditor  -Ofast -g -DNDEBUG -std=c++11 -m64 -std=c++0x -fno-operator-names -fno-exceptions -DQT_NO_EXCEPTIONS -Wno-gnu-zero-variadic-macro-arguments -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Wvla -Wdate-time -fPIC -fvisibility=hidden -fvisibility-inlines-hidden   -Wno-missing-field-initializers -Werror=undefined-bool-conversion -Werror=tautological-undefined-compare -Wdocumentation -Wno-gnu-zero-variadic-macro-arguments -pedantic -fPIC -std=gnu++11 -o CMakeFiles/KDevPlatformInterfaces.dir/iplugin.cpp.o -c /opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work/kf5-kdevelop-5/kdevplatform/interfaces/iplugin.cpp
In file included from /opt/local/var/lnxports/build/_opt_local_site-ports_kf5_kf5-kdevelop/kf5-kdevelop-devel/work/kf5-kdevelop-5/kdevplatform/interfaces/iplugin.cpp:207:
/home/bertin/work/src/Scratch/KDE/KF5/kdevld-lnx-work/build/kdevplatform/interfaces/KDevPlatformInterfaces_autogen/include/moc_iplugin.cpp:9:10: fatal error: 
      '../../../../../../kdevelop-git-5/kdevplatform/interfaces/iplugin.h' file not found
#include "../../../../../../kdevelop-git-5/kdevplatform/interfaces/iplugin.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [kdevplatform/interfaces/CMakeFiles/KDevPlatformInterfaces.dir/iplugin.cpp.o] Error 1


Thanks,
R.


More information about the CMake mailing list