[cmake-developers] Adding automatic checks for required targets in target-export files ?

Alexander Neundorf neundorf at kde.org
Sat Feb 16 12:32:55 EST 2013


On Wednesday 13 February 2013, Brad King wrote:
> On 02/12/2013 05:26 PM, Alexander Neundorf wrote:
> >> define a directory property that targets files can populate.  It is
> >> simply
> > 
> >> a list of target names that must exist by the time the directory is done:
> > A first try is now on stage in the ConfigFileTargetChecks4 branch.
> 
> It looks like you rebased an Eclipse change to start the topic.
> Please remove that commit.
> 
> > Tests and docs are still missing, error messages are not good yet, etc.,
> > but it should basically work.
> > Please have a look at it, especially at the last commit (c80d330).
> 
> It's a good start.  Please add docs/tests.  That will be much easier
> to review as I can run the test and look at the generated code.

There's another try now in ConfigFileTargetChecks5.
The export-file now warns if a target does not exist, but does not error out.
Later on in cmComputeLinkDepends cmake checks whether the imported targets 
actually exist, and errors out if not.
This should keep all (accidentially) working projects working, fail at cmake 
time for all projects which were failing until now at build time, and still 
warn all projects which have the find_package() order wrong.

This is what you get with wrong order:

$ make rebuild_cache
Running CMake to regenerate build system...
...
CMake Warning (dev) at 
/opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsTargets.cmake:97 (message):
  The following IMPORTED targets are required, but do not exist yet:
  kdeqt5staging

  This will cause errors in target_link_libraries() if these IMPORTED targets
  still do not exist then.  Import the targets according to their
  dependencies to remove this warning.
Call Stack (most recent call first):
  /opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsConfig.cmake:37 (include)
  /opt/extra-cmake-modules/share/ECM-0.0.7/find-modules/FindKF5.cmake:127 
(find_package)
  CMakeLists.txt:13 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/src/kde-
git/KDE/kdelibs/superbuild/b/kconfig
$ 


This is what you get if an imported target is missing:

$ make rebuild_cache
Running CMake to regenerate build system...
...
CMake Warning (dev) at 
/opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsTargets.cmake:97 (message):
  The following IMPORTED targets are required, but do not exist yet:
  kdeqt5staging

  This will cause errors in target_link_libraries() if these IMPORTED targets
  still do not exist then.  Import the targets according to their
  dependencies to remove this warning.
Call Stack (most recent call first):
  /opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsConfig.cmake:37 (include)
  /opt/extra-cmake-modules/share/ECM-0.0.7/find-modules/FindKF5.cmake:127 
(find_package)
  CMakeLists.txt:13 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
...

-- Configuring done
CMake Error at src/core/CMakeLists.txt:15 (add_library):
  Target "kconfigcore" links to IMPORTED library "kdeqt5staging" , but this
  library target has not been imported.

CMake Error at src/core/CMakeLists.txt:15 (add_library):
  Target "kconfigcore" links to IMPORTED library "kdeqt5staging" , but this
  library target has not been imported.
...

-- Generating done
-- Build files have been written to: /home/alex/src/kde-
git/KDE/kdelibs/superbuild/b/kconfig
make: *** [rebuild_cache] Error 1
$ 


Attached is a generated export-file.
I'm still working on the tests.
I'm not sure I have to add much documentation.
Maybe for the internally used variable ?

Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kcoreaddonsTargets.cmake
Type: text/x-cmake
Size: 3901 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20130216/595001bd/attachment-0002.bin>


More information about the cmake-developers mailing list