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:
CppTools::CppModelManager* modelManager = CppTools::CppModelManager::instance();
Project* project=SessionManager::startupProject();
CppTools::ProjectInfo info=modelManager->projectInfo(project);
CppTools::ProjectPart::HeaderPaths includePath=info.headerPaths();
const QSet<QString> sourceFiles=info.sourceFiles();
CppTools::CppModelManager* modelManager = CppTools::CppModelManager::instance();
Project* project=SessionManager::startupProject();
CppTools::ProjectInfo info=modelManager->projectInfo(project);
CppTools::ProjectPart::HeaderPaths includePath=info.headerPaths();
QByteArray defs=info.defines();
const QSet<QString> sourceFiles=info.sourceFiles();
To copy to clipboard, switch view to plain text mode
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:
HEADERS += main/file1.h
CONFIG(with_smth) {
HEADERS += dynamic/file2.h
}
SOURCES += main/file1.cpp
CONFIG(with_smth) {
SOURCES += dynamic/file2.cpp
}
INCLUDEPATH += main
CONFIG(with_smth) {
INCLUDEPATH += dynamic
}
HEADERS += main/file1.h
CONFIG(with_smth) {
HEADERS += dynamic/file2.h
}
SOURCES += main/file1.cpp
CONFIG(with_smth) {
SOURCES += dynamic/file2.cpp
}
INCLUDEPATH += main
CONFIG(with_smth) {
INCLUDEPATH += dynamic
}
To copy to clipboard, switch view to plain text mode
In such case I have file1.cpp and file2.cpp, but only ./main in include paths and file2.h cannot be resolved.
Is there anothe way to get project information from Qt Creator internals?
Bookmarks