Skip to content

Qt5 Simple Variables, master branch (2019.03.11.)

While looking at ATLINFR-2967 I ran into a very annoying problem. After fixing one issue with $QTLIB, I ran into this error while trying to build VP1TrkAuxAlgs on its own on top of the Athena nightly:

...
-- Configuring done
CMake Error at /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-03-10T2143/Athena/22.0.1/InstallArea/x86_64-centos7-gcc8-opt/cmake/modules/AtlasLibraryFunctions.cmake:217 (add_library):
  Target "VP1TrkAuxAlgs" links to target "Qt5::Gui" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-03-10T2143/Athena/22.0.1/InstallArea/x86_64-centos7-gcc8-opt/cmake/modules/AtlasLibraryFunctions.cmake:396 (atlas_add_library)
  /home/krasznaa/projects/qt5/athena/graphics/VP1/VP1TrkAuxAlgs/CMakeLists.txt:25 (atlas_add_component)


CMake Error at /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-03-10T2143/Athena/22.0.1/InstallArea/x86_64-centos7-gcc8-opt/cmake/modules/AtlasLibraryFunctions.cmake:217 (add_library):
  Target "VP1TrkAuxAlgs" links to target "Qt5::PrintSupport" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-03-10T2143/Athena/22.0.1/InstallArea/x86_64-centos7-gcc8-opt/cmake/modules/AtlasLibraryFunctions.cmake:396 (atlas_add_library)
  /home/krasznaa/projects/qt5/athena/graphics/VP1/VP1TrkAuxAlgs/CMakeLists.txt:25 (atlas_add_component)
...

The problem here is that using imported targets in the VP1 packages is unfortunately not as robust as I hoped. What happens in this case is that VP1TrkAuxAlgs is linked against VP1Base, which in turn is linked against Qt5::Gui and a few other Qt5 libraries. Now, VP1TrkAuxAlgs does not directly depend on Qt5::Gui. So it doesn't list it in its find_package(Qt5...) call. (Correctly.)

But the CMake description created for VP1Base lists Qt5::Gui as a dependent library. It lists this name and not the physical file(s) that was linked to the library, because that's just how CMake works. (For good reasons.) But this means that in order to build VP1TrkAuxAlgs as part of the WorkDir project, one needs to "find" Qt5 libraries that VP1TrkAuxAlgs does not directly depend on.

Unfortunately as long as we use the imported targets provided by Qt5, we'll always have this issue. So with this update I taught FindQt5.cmake how to set up the ${QT5_INCLUDE_DIRS} and ${QT5_LIBRARIES} variables based on the imported targets provided by Qt5. This will allow us to (possibly) one by one switch the VP1 packages to using these variables instead of the imported targets. Making it possible to use the VP1 libraries more easily in downstream projects. (Like WorkArea...)

Merge request reports

Loading