Op 10-3-2011 5:09, Campbell Barton schreef:
or parses the -D options and uses them ? > > If so, please add this to the cmake bug tracker as feature request. >
Hi,
We were struggling with the same dificulties. The previously provided patch for CMake brought us closer to the solution. My collegae has created the required patch for QtCreator 2.1.0 which actually uses the defines created by the CMake patch.
Attached. Cheers
diff -crb qt-creator-2.1.0-src-orig/src/plugins/cmakeprojectmanager/cmakeproject.cpp qt-creator-2.1.0-src/src/plugins/cmakeprojectmanager/cmakeproject.cpp *** qt-creator-2.1.0-src-orig/src/plugins/cmakeprojectmanager/cmakeproject.cpp 2011-02-11 11:29:12.000000000 +0100 --- qt-creator-2.1.0-src/src/plugins/cmakeprojectmanager/cmakeproject.cpp 2011-03-10 14:18:50.342454998 +0100 *************** *** 248,265 **** allIncludePaths.append(projectDirectory()); allIncludePaths.append(cbpparser.includeFiles()); CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); if (modelmanager) { CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this); if (pinfo.includePaths != allIncludePaths || pinfo.sourceFiles != m_files ! || pinfo.defines != activeBC->toolChain()->predefinedMacros() || pinfo.frameworkPaths != allFrameworkPaths) { pinfo.includePaths = allIncludePaths; // TODO we only want C++ files, not all other stuff that might be in the project pinfo.sourceFiles = m_files; ! pinfo.defines = activeBC->toolChain()->predefinedMacros(); // TODO this is to simplistic pinfo.frameworkPaths = allFrameworkPaths; modelmanager->updateProjectInfo(pinfo); m_codeModelFuture.cancel(); --- 248,270 ---- allIncludePaths.append(projectDirectory()); allIncludePaths.append(cbpparser.includeFiles()); + + QByteArray allDefines; + allDefines.append(activeBC->toolChain()->predefinedMacros()); + allDefines.append(cbpparser.defines()); + CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); if (modelmanager) { CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this); if (pinfo.includePaths != allIncludePaths || pinfo.sourceFiles != m_files ! || pinfo.defines != allDefines || pinfo.frameworkPaths != allFrameworkPaths) { pinfo.includePaths = allIncludePaths; // TODO we only want C++ files, not all other stuff that might be in the project pinfo.sourceFiles = m_files; ! pinfo.defines = allDefines; pinfo.frameworkPaths = allFrameworkPaths; modelmanager->updateProjectInfo(pinfo); m_codeModelFuture.cancel(); *************** *** 892,897 **** --- 897,910 ---- void CMakeCbpParser::parseAdd() { m_includeFiles.append(attributes().value("directory").toString()); + QString compilerOption = attributes().value("option").toString(); + m_compilerOptions.append(compilerOption); + //assume only one compileroption is placed in the option attribute + if(compilerOption.indexOf("-D") != -1) { + m_defines.append("#define "); + m_defines.append(compilerOption.mid(compilerOption.indexOf("-D")+2).replace("=", " ").toAscii()); + m_defines.append("\n"); + } while (!atEnd()) { readNext(); if (isEndElement()) { *************** *** 989,994 **** --- 1002,1017 ---- return m_includeFiles; } + QStringList CMakeCbpParser::compilerOptions() + { + return m_compilerOptions; + } + + QByteArray CMakeCbpParser::defines() + { + return m_defines; + } + QList<CMakeBuildTarget> CMakeCbpParser::buildTargets() { return m_buildTargets; diff -crb qt-creator-2.1.0-src-orig/src/plugins/cmakeprojectmanager/cmakeproject.h qt-creator-2.1.0-src/src/plugins/cmakeprojectmanager/cmakeproject.h *** qt-creator-2.1.0-src-orig/src/plugins/cmakeprojectmanager/cmakeproject.h 2011-02-11 11:29:12.000000000 +0100 --- qt-creator-2.1.0-src/src/plugins/cmakeprojectmanager/cmakeproject.h 2011-03-10 14:01:37.412455006 +0100 *************** *** 147,152 **** --- 147,154 ---- QList<ProjectExplorer::FileNode *> fileList(); QList<ProjectExplorer::FileNode *> cmakeFileList(); QStringList includeFiles(); + QStringList compilerOptions(); + QByteArray defines(); QList<CMakeBuildTarget> buildTargets(); QString projectName() const; QString compilerName() const; *************** *** 172,177 **** --- 174,181 ---- QSet<QString> m_processedUnits; bool m_parsingCmakeUnit; QStringList m_includeFiles; + QStringList m_compilerOptions; + QByteArray m_defines; CMakeBuildTarget m_buildTarget; bool m_buildTargetType;
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake