Qt5 cmake stuff

Alexander Neundorf neundorf at kde.org
Mon May 14 21:13:44 UTC 2012


On Monday 14 May 2012, Alexander Neundorf wrote:
> On Monday 14 May 2012, David Faure wrote:
> > On Monday 14 May 2012 18:10:19 David Faure wrote:
> > > Hi (Steve),
> > > 
> > > It seems that updating Qt5 to the latest master broke my
> > > kdelibs-frameworks-qt5 build?
> > > 
> > > CMake Error at
> > > /d/qt/5/qtbase-master/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:60
> > > (add_library): add_library cannot create imported target "Qt5::Core"
> > > because another target with the same name already exists.
> > > Call Stack (most recent call first):
> > > 
> > > /d/kde/inst/kde_frameworks-qt5/share/ECM-0.0.4/find-modules/FindQt5Tran
> > > si ti onal.cmake:2 (find_package) tier1/itemmodels/CMakeLists.txt:19
> > > (find_package)
> > > 
> > > (and many more such errors about duplicate targets)
> > > 
> > > Unfortunately cmake doesn't say *where* it saw the target the first
> > > time, so I have no clue how to debug this.
> > 
> > Actually it seems to happen both times in the same file.
> > It's trying to prevent calling add_library(Qt5::Core SHARED IMPORTED)
> > twice, but the mechanism to prevent that is not working...
> > 
> > Qt5CoreConfig.cmake says:
> > 
> > get_property(_qt5CoreTargetExists DIRECTORY PROPERTY _Qt5Core_target)
> > if (NOT _qt5CoreTargetExists)
> > 
> >     set_property(DIRECTORY PROPERTY _Qt5Core_target TRUE)
> >     message(STATUS "DF: Qt5CoreConfig.cmake add_library(Qt5::Core SHARED
> > 
> > IMPORTED)") add_library(Qt5::Core SHARED IMPORTED)
> > endif()
> > 
> > but the output from make says
> > [...]
> > -- DF: Qt5CoreConfig.cmake add_library(Qt5::Core SHARED IMPORTED)
> > [...]
> > -- DF: Qt5CoreConfig.cmake add_library(Qt5::Core SHARED IMPORTED)
> > [...]
> > 
> > so clearly this "directory property" stuff isn't working.
> 
> I'm quite sure it, but maybe not as we think it does ;-)

A directory property seems to be only valid for this directory, and is not 
inherited to subdirs.
This is kind of in sync with the docs for set_property(... DIRECTORY ...):
"DIRECTORY scope defaults to the current directory but another directory 
(already processed by CMake) may be named by full or relative path."

but not really for set_directory_properties():
"Set a property for the current directory and subdirectories."

I just checked, this indeed changed (broke ?) from cmake 2.6.4 to 2.8.0.
So this looks really like a regression in cmake :-/.

For now, you can change the code e.g. to 
if (NOT TARGET Qt5::Core)
  message(STATUS "DF: Qt5CoreConfig.cmake add_library(Qt5::Core)")
  add_library(Qt5::Core SHARED IMPORTED)
endif()

OR

if (NOT _qt5CoreTargetExists)
  set(_Qt5Core_target TRUE)
  message(STATUS "DF: Qt5CoreConfig.cmake add_library(Qt5::Core)")
  add_library(Qt5::Core SHARED IMPORTED)
endif()

both should fix it for now.
 
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20120514/7b374c43/attachment.html>


More information about the Kde-frameworks-devel mailing list