forked from qt-creator/qt-creator
CMake: Support Build File also from header files
Fixes: QTCREATORBUG-26164 Change-Id: Iaa2fdd34cffad07be668ca7142a8ffa2c373d325 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
9908f623f6
commit
da0cb254b2
@@ -16,6 +16,7 @@
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <cppeditor/cpptoolsreuse.h>
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -217,10 +218,17 @@ void CMakeManager::buildFile(Node *node)
|
||||
CMakeTargetNode *targetNode = dynamic_cast<CMakeTargetNode *>(fileNode->parentProjectNode());
|
||||
if (!targetNode)
|
||||
return;
|
||||
Utils::FilePath filePath = fileNode->filePath();
|
||||
if (filePath.fileName().contains(".h")) {
|
||||
bool wasHeader = false;
|
||||
const QString sourceFile = CppEditor::correspondingHeaderOrSource(filePath.toString(), &wasHeader);
|
||||
if (wasHeader && !sourceFile.isEmpty())
|
||||
filePath = Utils::FilePath::fromString(sourceFile);
|
||||
}
|
||||
Target *target = project->activeTarget();
|
||||
QTC_ASSERT(target, return);
|
||||
const QString generator = CMakeGeneratorKitAspect::generator(target->kit());
|
||||
const QString relativeSource = fileNode->filePath().relativeChildPath(targetNode->filePath()).toString();
|
||||
const QString relativeSource = filePath.relativeChildPath(targetNode->filePath()).toString();
|
||||
const QString objExtension = Utils::HostOsInfo::isWindowsHost() ? QString(".obj") : QString(".o");
|
||||
Utils::FilePath targetBase;
|
||||
BuildConfiguration *bc = target->activeBuildConfiguration();
|
||||
|
||||
Reference in New Issue
Block a user