[Qt-creator] CppTools::ProjectInfo project sources and include paths

Roman Nikiforov roman at nikiforoff.de
Mon Feb 2 16:31:24 CET 2015


Hello,
I'm writing my first plugin for Qt Creator to integrate PC Lint check into
projects. In order to provide Lint with required information I get active
project information this way:

   1. CppTools::CppModelManager* modelManager = CppTools::CppModelManager::
   instance();
   2. Project* project=SessionManager::startupProject();
   3. CppTools::ProjectInfo info=modelManager->projectInfo(project);
   4. CppTools::ProjectPart::HeaderPaths includePath=info.headerPaths();
   5. QByteArray <http://qt-project.org/doc/qt-4.8/qbytearray.html> defs=
   info.defines();
   6. const QSet<QString> sourceFiles=info.sourceFiles();

The problem is that if I have conditions in qmake .pro file and some
sources and include paths are added only for special configuration, I still
get all source files from ProjectInfo, but include paths only for active
configuration. Consequently Lint cannot resolve some includes and stops
with error. Example application.pro:


   1. HEADERS += main/file1.h
   2. CONFIG(with_smth) {
   3. HEADERS += dynamic/file2.h
   4. }
   5. SOURCES += main/file1.cpp
   6. CONFIG(with_smth) {
   7. SOURCES += dynamic/file2.cpp
   8. }
   9. INCLUDEPATH += main
   10. CONFIG(with_smth) {
   11. INCLUDEPATH += dynamic
   12. }

In such case even if with_smth is not defined I have file1.cpp and
file2.cpp as sources, but only ./main as include path and file2.h/cpp
cannot be resolved.
Is there another way to get project information (active sources and include
paths) from Qt Creator internals?

-- 
Regards
Roman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150202/9c60ca06/attachment.html>


More information about the Qt-creator mailing list