[Qt-creator] CMake and Include Files

roberto.raggi at nokia.com roberto.raggi at nokia.com
Tue Jul 14 21:14:24 CEST 2009


Hi,

Take a look at qtcreator/tests/manual/preprocessor/
It shows how to find the header files included by QtCore.

ciao robe

Il giorno 14/lug/2009, alle ore 19.57, "ext James" <agnosticpope at gmail.com<mailto:agnosticpope at gmail.com>> ha scritto:

I've tried this more or less -- in fact I have my own parser for the current XML file generated from cmake code blocks option.  Haven't messed around with creating my own XML file with cmake though.

So, I guess what I don't understand, is that it seems like the CMakelists.txt files are themselves incomplete and while one could write another parser for them in Cmake, then how would you find the headers?  Wouldn't they still be missing?  Or does cmake find them in some way?  After all, cmake is a build manager, not a code manager, and at some basic level, it only cares about include paths, not include files.  I wrote my own native cmakelist.txt parser for creator a while back (and still have it somewhere), so I'm somewhat familiar with the problem/question.

If you'd like, I can post my current solution for parsing which seems to do a reasonably good job, based off of the current XML file from codeblocks.  I'm using it to work on a fairly large project (a few hundred source files, some UI files, multiple directories) and the results are much better than the current release, IMHO, but it's not perfect, since in the end, I use a heuristic to try and find headers that aren't in cmakelists.

--James


On Tue, Jul 14, 2009 at 12:15 PM, Mike Jackson <<mailto:imikejackson at gmail.com>imikejackson at gmail.com<mailto:imikejackson at gmail.com>> wrote:
At some point Creator would actually generate a KDevelop project file
from your cmake based project by actually invoking CMake from creator.
This created an XML based file that Creator would then parse to gain
information about what/where to build things. This was slow and error
prone and tended to be missing information. There was a discussion on
the IRC channel that basically said there needs to be a "QtCreator"
option for CMake. CMake would then generate an XML File that has all
the information that QtCreator would need to create a project. It was
stated in the same IRC conversation that the only thing closest to what
was needed was the Visual studio project/solution files (since they are
XML). Using the Visual Studio Generator as a starting point for
creating a "QtCreator Generator" was then born. Of course once you have
cmake generating some XML files then you need QtCreator to be able to
parse the information contained in them.

 So to get started you would need to do the following:
Pull the Latest CVS version of CMake.
Study the code to figure out what needs to be done to create a new generator.
Write the new generator for QtCreator (or append to the KDevelop one).
Test said generator on a project.

Clone the latest version of QtCreator.
Find where the parsing of the XML files is happening
Add code to parse more detailed information from the new xml files that
were generated earlier.
Compile QtCreator
Test it out with the new project xml files that were generated with
CMake from above.


There is also the idea to have CMake generate .pro files but this was
quickly passed off as being too labor intensive/difficult to create.

Of course the third option would be for Qt to drop qmake and go with
CMake instead ;-)

Mike Jackson

On 2009-07-13 22:40:50 -0400, James <<mailto:agnosticpope at gmail.com>agnosticpope at gmail.com<mailto:agnosticpope at gmail.com>> said:

>
> The idea of creating a new CMake parsers sounds interesting, but how would
> that work exactly?  Part of the problem is that include files aren't
> contained in the CMake files, so you're still left, at some level, with
> parsing the actual c++ files or just adding everything ending in .h.
>
> How does visual studio xml work with CMake?  I took a look, but couldn't
> find a single header file mentioned in anything...perhaps I'm looking in the
> wrong place (I'm not terribly familiar with VS though).
>
> --James
>
> On Fri, Jul 10, 2009 at 8:28 AM, Mike Jackson <<mailto:imikejackson at gmail.com>imikejackson at gmail.com<mailto:imikejackson at gmail.com>>wrote:
>
>> I tried Creator with CMake but there was _too_ much that I still had to
>> do on my own for each project to get things to work.
>> I know that several ideas had been discussed (mainly in the irc
>> channel) like creating a new generator for CMake that would produce xml
>> files that had all the needed information. I don't think this is going
>> anywhere as it really needs someone with the time to jump into the
>> catch-22 loop and start coding it up, both in CMake and in Creator.
>>
>> You need CMake to generate a QtCreator readable XML file. And you
>> need Creator to be able to parse it. I think after that a lot of the
>> issues with code completion would be mitigated as all the proper
>> include directories would be listed in the xml file that cmake produced.
>>
>> The Visual Studio XML files are pretty close to what is needed as
>> they have the most information. So starting with a clone of the Visual
>> Studio CMake Generator code might be a good start.
>>
>> Just my thoughts..
>>
>> Mike Jackson
>>
>> On 2009-07-07 22:28:33 -0400, James <<mailto:agnosticpope at gmail.com>agnosticpope at gmail.com<mailto:agnosticpope at gmail.com>> said:
>>
>>>
>>> Since I've been using Creator (1.0), cmake support has gotten much
>> better.
>>>
>>> Unfortunately, unless there's some step I'm missing, it still doesn't
>> parse
>>> files for autocompletion information.  Additionally, since CMake files
>> don't
>>> necessarily include all the headers, the project tree itself may not even
>> be
>>> complete.
>>>
>>> While I've been using it, I was maintaining a small modification that
>> looked
>>> for a foo.h whenever parsing a foo.c++ (and if found added it) and also
>> used
>>> the file extension to sort the headers from the source files.
>>> Unfortunately, things started behaving strangely this Monday as I think
>> the
>>> most recent mod broke my change;)
>>>
>>> I'm not wholly happy with my solution, and I'd be more than happy to help
>> or
>>> write a proper solution to better accommodate CMake.  IMHO, there's two
>>> issues: adding all headers properly and properly catagorizing the files
>> so
>>> that they can be parsed.  There's various ways of doing this, none of
>> which
>>> are very good.  There's my current solution, which misses files.  It'd
>> also
>>> be possible to parse every source file and look for includes, maybe with
>>> some assumption about having them at the beginning, but probably would be
>>> very slow.  A third would be to just look in every directory parsed for
>>> header files, which, again, may get stuff that's unused.
>>>
>>> What are the community/trolltech's thoughts on this?  Or am I the only
>> one
>>> who uses Creator with CMake;)
>>>
>>> --James
>>
>> _______________________________________________
>> Qt-creator mailing list
>> <mailto:Qt-creator at trolltech.com> Qt-creator at trolltech.com<mailto:Qt-creator at trolltech.com>
>> <http://lists.trolltech.com/mailman/listinfo/qt-creator> http://lists.trolltech.com/mailman/listinfo/qt-creator
>>
>
>
> The idea of creating a new CMake parsers sounds interesting, but how would =
> that work exactly?=A0 Part of the problem is that include files aren&#39;t =
> contained in the CMake files, so you&#39;re still left, at some level, with=
>  parsing the actual c++ files or just adding everything ending in .h.<br>
> <br>How does visual studio xml work with CMake?=A0 I took a look, but could=
> n&#39;t find a single header file mentioned in anything...perhaps I&#39;m l=
> ooking in the wrong place (I&#39;m not terribly familiar with VS though).<b=
> r>
> <br>--James<br><br><div class=3D"gmail_quote">On Fri, Jul 10, 2009 at 8:28 =
> AM, Mike Jackson <span dir=3D"ltr">&lt;<a href=3D"mailto:imikejackson at gmail<mailto:imikejackson at gmail>=
> .com"><mailto:imikejackson at gmail.com>imikejackson at gmail.com<mailto:imikejackson at gmail.com></a>&gt;</span> wrote:<br><blockquote class=3D"=
> gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0p=
> t 0pt 0pt 0.8ex; padding-left: 1ex;">
> I tried Creator with CMake but there was _too_ much that I still had to<br>
> do on my own for each project to get things to work.<br>
>  =A0I know that several ideas had been discussed (mainly in the irc<br>
> channel) like creating a new generator for CMake that would produce xml<br>
> files that had all the needed information. I don&#39;t think this is going<=
> br>
> anywhere as it really needs someone with the time to jump into the<br>
> catch-22 loop and start coding it up, both in CMake and in Creator.<br>
> <br>
>  =A0You need CMake to generate a QtCreator readable XML file. And you<br>
> need Creator to be able to parse it. I think after that a lot of the<br>
> issues with code completion would be mitigated as all the proper<br>
> include directories would be listed in the xml file that cmake produced.<br=
>>
> <br>
>  =A0The Visual Studio XML files are pretty close to what is needed as<br>
> they have the most information. So starting with a clone of the Visual<br>
> Studio CMake Generator code might be a good start.<br>
> <br>
> =A0Just my thoughts..<br>
> <br>
> Mike Jackson<br>
> <div><div></div><div class=3D"h5"><br>
> On 2009-07-07 22:28:33 -0400, James &lt;<a href=3D"mailto:agnosticpope at gmai<mailto:agnosticpope at gmai>=
> <http://l.com> l.com<http://l.com>"><mailto:agnosticpope at gmail.com>agnosticpope at gmail.com<mailto:agnosticpope at gmail.com></a>&gt; said:<br>
> <br>
> &gt;<br>
> &gt; Since I&#39;ve been using Creator (1.0), cmake support has gotten much=
>  better.<br>
> &gt;<br>
> &gt; Unfortunately, unless there&#39;s some step I&#39;m missing, it still =
> doesn&#39;t parse<br>
> &gt; files for autocompletion information. =A0Additionally, since CMake fil=
> es don&#39;t<br>
> &gt; necessarily include all the headers, the project tree itself may not e=
> ven be<br>
> &gt; complete.<br>
> &gt;<br>
> &gt; While I&#39;ve been using it, I was maintaining a small modification t=
> hat looked<br>
> &gt; for a foo.h whenever parsing a foo.c++ (and if found added it) and als=
> o used<br>
> &gt; the file extension to sort the headers from the source files.<br>
> &gt; Unfortunately, things started behaving strangely this Monday as I thin=
> k the<br>
> &gt; most recent mod broke my change;)<br>
> &gt;<br>
> &gt; I&#39;m not wholly happy with my solution, and I&#39;d be more than ha=
> ppy to help or<br>
> &gt; write a proper solution to better accommodate CMake. =A0IMHO, there&#3=
> 9;s two<br>
> &gt; issues: adding all headers properly and properly catagorizing the file=
> s so<br>
> &gt; that they can be parsed. =A0There&#39;s various ways of doing this, no=
> ne of which<br>
> &gt; are very good. =A0There&#39;s my current solution, which misses files.=
>  =A0It&#39;d also<br>
> &gt; be possible to parse every source file and look for includes, maybe wi=
> th<br>
> &gt; some assumption about having them at the beginning, but probably would=
>  be<br>
> &gt; very slow. =A0A third would be to just look in every directory parsed =
> for<br>
> &gt; header files, which, again, may get stuff that&#39;s unused.<br>
> &gt;<br>
> &gt; What are the community/trolltech&#39;s thoughts on this? =A0Or am I th=
> e only one<br>
> &gt; who uses Creator with CMake;)<br>
> &gt;<br>
> &gt; --James<br>
> <br>
> </div></div>_______________________________________________<br>
> Qt-creator mailing list<br>
> <a href=3D"mailto:<mailto:Qt-creator at trolltech.com>Qt-creator at trolltech.com<mailto:Qt-creator at trolltech.com>"><mailto:Qt-creator at trolltech.com>Qt-creator at trolltech.com<mailto:Qt-creator at trolltech.com></a><br=
>>
> <a href=3D"<http://lists.trolltech.com/mailman/listinfo/qt-creator>http://lists.trolltech.com/mailman/listinfo/qt-creator" target=
> =3D"_blank"><http://lists.trolltech.com/mailman/listinfo/qt-creator>http://lists.trolltech.com/mailman/listinfo/qt-creator</a><br>
> </blockquote></div><br>


_______________________________________________
Qt-creator mailing list
<mailto:Qt-creator at trolltech.com>Qt-creator at trolltech.com<mailto:Qt-creator at trolltech.com>
<http://lists.trolltech.com/mailman/listinfo/qt-creator>http://lists.trolltech.com/mailman/listinfo/qt-creator

_______________________________________________
Qt-creator mailing list
Qt-creator at trolltech.com<mailto:Qt-creator at trolltech.com>
http://lists.trolltech.com/mailman/listinfo/qt-creator
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20090714/5623a8c4/attachment.html 


More information about the Qt-creator-old mailing list