Discussion:
CMake projects & "Show Targets"
René J.V. Bertin
2016-07-04 08:57:55 UTC
Permalink
Hi,

The cmake project manager apparently no longer supports chdir'ing to a project subdirectory to build only that part of the project, so it's important that the target list is shown reliably. Yet that is not the case for me. I have projects where the targets are shown (though no longer "expandable" to show the files they depend on), and projects where the "Show Targets" button doesn't do anything. I think that's even the case with most projects I have.

Are there conditions to be met for the list of targets to be known and/or shown? Does one need to create the project in KDevelop for instance (= run the initial cmake in a clean build directory from within KDevelop)?

R
Aleix Pol
2016-07-04 23:11:48 UTC
Permalink
Post by René J.V. Bertin
Hi,
The cmake project manager apparently no longer supports chdir'ing to a project subdirectory to build only that part of the project, so it's important that the target list is shown reliably. Yet that is not the case for me. I have projects where the targets are shown (though no longer "expandable" to show the files they depend on), and projects where the "Show Targets" button doesn't do anything. I think that's even the case with most projects I have.
Are there conditions to be met for the list of targets to be known and/or shown? Does one need to create the project in KDevelop for instance (= run the initial cmake in a clean build directory from within KDevelop)?
We're basically fetching the targets from
<builddir>/CMakeFiles/TargetDirectories.txt.

We don't have information about what's in the target nowadays (I've
tried to make cmake offer it, and they took a very complex turn which
didn't result in much).

Help is welcome, as it is it won't get more features.

Aleix
René J.V. Bertin
2016-07-05 09:20:41 UTC
Permalink
Post by Aleix Pol
We're basically fetching the targets from
<builddir>/CMakeFiles/TargetDirectories.txt.
Thanks, what am I looking for in that file?
I have an example project that's not too large and for which `make -C builddir help` lists the appropriate targets which do *not* show up in KDevelop's "Show Targets" mode.
That project's TargetDirectories.txt file only contains references to *.dir items and I don't really see how to determine which of those contain a target you'd want to list in "Show Targets".
Post by Aleix Pol
We don't have information about what's in the target nowadays (I've
tried to make cmake offer it, and they took a very complex turn which
didn't result in much).
Help is welcome, as it is it won't get more features.
Expanding targets to show the files they depend on is useful at times but not crucial. Probably not worth investing a lot of time if the information is (too) hard to obtain. Each CMakeFiles/target.dir should have a build.make file which should contain a target_OBJECTS variable listing the object files on which the target depends, but you surely know that already. In my example project I also see lines like
Post by Aleix Pol
qt5/style/CMakeFiles/qtcurve-qt5.dir/requires: qt5/style/CMakeFiles/qtcurve-qt5.dir/prepolish.cpp.o.requires
qt5/style/CMakeFiles/qtcurve-qt5.dir/requires: qt5/style/CMakeFiles/qtcurve-qt5.dir/qtcurve.cpp.o.requires
Looks like the hard part would be to get the *_OBJECTS variable read in reliably (or construct the equivalent list of object files from those .requires lines) and then map the object files back to source files.

Anyway, I find it more convenient to be able to build just a subdirectory, whether that's because I don't know which of the targets in there to build, or because I want to build all of them. It should be trivial to implement that; just chdir to the selected directory and invoke make, or use the -C option (not sure if this would make sense with ninja). I've already offered once to look into that ... if someone could point me to the appropriate class. I don't think I ever saw a reaction to that.

R.

Loading...