CMake 3.6: automoc and autorcc insert relative path data into filenames and symbols
I upgraded to CMake 3.6 yesterday and the outputs of automoc and autorcc have changed in ways which break builds.
- In 3.5 autorcc created a symbol called
qInitResources_VectorTools
. In 3.6 this has changed toqInitResources_extra_vectortools_VectorTools_Core_VectorTools_src_VectorTools
, where the extra text is the relative path to the QRC file. Needless to say this breaks the build. The QRC is added to the project with the commandADD_LIBRARY(vectortools_ui STATIC [other files] ../VectorTools.qrc)
. - MOC output is also broken. My project now includes a generated CPP file with the line
#include "../../../../../../../../../../../../../../../../../project/extra/vectortools/VectorTools/Core/VectorTools/include/VectorTools/UI/VectorWindow.h"
. This path can't be opened by the IDE or compiler, presumably because it's appended to the CPP filename to create a path that's over Windows' 260 character limit. Manually shortening it (e.g. by switching to an absolute path) fixes the problem. - When opening an automoc file in Visual Studio, part of the path contains forward slashes. This doesn't prevent the file from being opened in the IDE but does prevent the "Open Containing Folder" feature from working.
Reverting to 3.5.2 fixes all of these problems.
It seems that the goal here was to prevent name collisions. An error would be a far more appropriate solution. The RCC symbol name is particularly bad as it's buried deep inside a series of auto-generated files and folders, and anyone who wasn't familiar with both Qt and CMake would be completely stumped.