MantisBT - CMake
View Issue Details
0015356CMakeCMakepublic2015-01-16 05:152015-11-02 09:13
Peter Kuemmel 
Nils Gladitz 
normalmajoralways
closedfixed 
AllAllAll
CMake 3.2 
CMake 3.3 
0015356: CodeBlocks: add target to which a file belongs to
IDEs like QtCreator parse the cbp file to figure out compile options for each file.

Currently it is not possible to figure out to which <Target title=> a file belongs to and the IDE has to guess a target which is mostly done by the file location.

But when there are multiple targets within the same directory with different options the IDE has no chance to do the mapping file<->target right.

A <Unit> part within <Target> would solve the problem.
No tags attached.
png qtcreator.png (130,302) 2015-03-11 17:46
https://public.kitware.com/Bug/file/5401/qtcreator.png
png
Issue History
2015-01-16 05:15Peter KuemmelNew Issue
2015-03-05 08:53Nils GladitzNote Added: 0038147
2015-03-05 12:30Peter KuemmelNote Added: 0038149
2015-03-05 12:39Nils GladitzNote Added: 0038150
2015-03-05 14:16Peter KuemmelNote Added: 0038151
2015-03-05 14:22Nils GladitzNote Added: 0038152
2015-03-06 03:53Nils GladitzNote Added: 0038155
2015-03-06 09:13Nils GladitzNote Added: 0038158
2015-03-07 10:17Peter KuemmelNote Added: 0038175
2015-03-09 07:36Nils GladitzNote Added: 0038181
2015-03-11 08:58Peter KuemmelNote Added: 0038200
2015-03-11 13:37Nils GladitzNote Added: 0038202
2015-03-11 17:28Peter KuemmelNote Added: 0038205
2015-03-11 17:46Nils GladitzFile Added: qtcreator.png
2015-03-11 17:46Nils GladitzNote Added: 0038206
2015-03-14 02:31Peter KuemmelNote Added: 0038210
2015-03-14 04:05Nils GladitzNote Added: 0038211
2015-03-14 04:05Nils GladitzStatusnew => resolved
2015-03-14 04:05Nils GladitzFixed in Version => CMake 3.3
2015-03-14 04:05Nils GladitzResolutionopen => fixed
2015-03-14 04:05Nils GladitzAssigned To => Nils Gladitz
2015-03-14 04:21Peter KuemmelNote Edited: 0038210bug_revision_view_page.php?bugnote_id=38210#r1728
2015-03-14 04:24Peter KuemmelNote Added: 0038212
2015-04-15 05:59Peter KuemmelNote Edited: 0038212bug_revision_view_page.php?bugnote_id=38212#r1756
2015-11-02 09:13Robert MaynardNote Added: 0039771
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038147)
Nils Gladitz   
2015-03-05 08:53   
It looks like the format allows for one or more <Option target="target-name"/> elements under each <Unit> element for this.

It also looks like QtCreator's cbp parser does not handle those (yet).
(0038149)
Peter Kuemmel   
2015-03-05 12:30   
Is this only available in CMake 3.2?
(0038150)
Nils Gladitz   
2015-03-05 12:39   
Is that in response to me? What do you mean specifically?
I was looking at the CodeBlocks's project specification and into what would be required in CMake and QtCreator but I haven't actually implemented anything.
(0038151)
Peter Kuemmel   
2015-03-05 14:16   
Yes, when I use cmake version 3.1.3, I don't see any <Option target="target-name"/> under <Unit>.

Is this already available in 3.2, or needs it to be implemented?
(0038152)
Nils Gladitz   
2015-03-05 14:22   
No like I said I was looking into what would be required to implement this hence this isn't implemented yet.

In CMake this looks simple enough but I am not really sure about what would be required in QtCreator.
(0038155)
Nils Gladitz   
2015-03-06 03:53   
I've given the CMake side a try:
https://github.com/ngladitz/cmake/commit/099b0cab1d12b5b3734342ac516c8d42c78cdef7 [^]
(0038158)
Nils Gladitz   
2015-03-06 09:13   
It looks like neither QtCreator nor CodeBlocks itself choke on the new elements and CodeBlocks does seems to properly associate source files with the targets that they belong to now.

I've merged to "next" for testing.
(0038175)
Peter Kuemmel   
2015-03-07 10:17   
I had a look at the QtCreator code:
https://codereview.qt-project.org/#/c/107991/ [^]

Related QtCreator bug:
https://bugreports.qt.io/browse/QTCREATORBUG-13695 [^]
(0038181)
Nils Gladitz   
2015-03-09 07:36   
Minor clarification; the earliest CMake release this could get into is 3.3 rather than 3.2.

I tried your QtCreator changes with this test case:
https://gist.github.com/ngladitz/a2ea8df64ba36bdf1077 [^]

In foo.cpp the code model seems to correctly see that FOO is defined and BAR isn't.

In bar.cpp however both FOO and BAR seem to be defined (expected would be that only BAR is defined).

With vanilla QtCreator 3.3.1 FOO is defined in both foo.cpp and bar.cpp and BAR is defined in neither.
(0038200)
Peter Kuemmel   
2015-03-11 08:58   
I've tested with your gist, and the code model now looks correct, but highlighting in the editor does not work; maybe different issue in qtcreator.
(0038202)
Nils Gladitz   
2015-03-11 13:37   
Thanks! It seems to work for me as well.
The highlighting defaults seem to have changed in QtCreator.

I changed "Text Editor" -> "Font & Colors" -> "Disabled Code" in the "Color Scheme" and it highlights as expected.

In "Tools" -> "C++" -> "Inspect C++ Code Model..." in the "Project Parts" tab "foo" seems to list foo.cpp twice under "Project Files" while "bar" shows bar.cpp only once.

Could that be an issue?
(0038205)
Peter Kuemmel   
2015-03-11 17:28   
Here still both ifdefs are disabled in both files, but there should be one enabled and one disabled.

> list foo.cpp twice under "Project Files"
Not here, have you build latest 3.4?
(0038206)
Nils Gladitz   
2015-03-11 17:46   
I used "Patch Set 4" (44694284a5290d5a065ae52246d83006770ac2ca) from the code review that you linked (screenshot attached).
(0038210)
Peter Kuemmel   
2015-03-14 02:31   
(edited on: 2015-03-14 04:21)
I abandoned creator patch, because it seems the file logic is completely path based, and the creator team there isn't very interested in CMake.

I tried CLion with your example, and there it works like expected! I will also have a look at Kdevelop.

So maybe it's time to move away from QtCreator until there is reliable meta information:
http://public.kitware.com/pipermail/cmake-developers/2015-March/024666.html [^]

(0038211)
Nils Gladitz   
2015-03-14 04:05   
I don't understand why that is an issue or what the issue even is given that this had the appearance of mostly working (see screenshot).

Thanks for trying though!

I'll resolve this issue given that the cmake part is now in master: http://www.cmake.org/gitweb?p=cmake.git;a=commit;h=099b0cab [^]
(0038212)
Peter Kuemmel   
2015-03-14 04:24   
(edited on: 2015-04-15 05:59)
Thanks, too. I hope someone of the creator guys has a look at it.

We should create a new QtCreator ticket when there is a CMake release which supports the target property, and upload the example project.

(0039771)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.