2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2019-08-06 12:41:46 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-04-24 10:29:43 +02:00
|
|
|
#include "builddirparameters.h"
|
|
|
|
|
#include "cmakebuildtarget.h"
|
|
|
|
|
#include "fileapireader.h"
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2022-05-02 18:02:37 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2019-08-09 11:22:49 +02:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2020-04-24 10:29:43 +02:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
#include <utils/temporarydirectory.h>
|
|
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
namespace CppEditor { class CppProjectUpdater; }
|
2021-09-27 17:26:40 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class ExtraCompiler;
|
|
|
|
|
class FolderNode;
|
|
|
|
|
}
|
2023-01-12 23:32:11 +01:00
|
|
|
namespace Utils { class QtcProcess; }
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
namespace CMakeProjectManager {
|
2020-03-19 18:36:22 +01:00
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
class CMakeBuildConfiguration;
|
2021-09-21 22:22:37 +02:00
|
|
|
class CMakeProject;
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2021-02-04 14:53:42 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// CMakeBuildSystem:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2020-01-29 04:15:25 +03:00
|
|
|
class CMakeBuildSystem final : public ProjectExplorer::BuildSystem
|
2019-08-06 12:41:46 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2019-10-25 09:55:32 +02:00
|
|
|
explicit CMakeBuildSystem(CMakeBuildConfiguration *bc);
|
2019-08-06 12:41:46 +02:00
|
|
|
~CMakeBuildSystem() final;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void triggerParsing() final;
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2019-10-22 14:55:51 +02:00
|
|
|
bool supportsAction(ProjectExplorer::Node *context,
|
|
|
|
|
ProjectExplorer::ProjectAction action,
|
2020-04-02 14:49:05 +02:00
|
|
|
const ProjectExplorer::Node *node) const final;
|
2019-10-22 14:55:51 +02:00
|
|
|
|
|
|
|
|
bool addFiles(ProjectExplorer::Node *context,
|
2021-07-14 16:49:42 +02:00
|
|
|
const Utils::FilePaths &filePaths, Utils::FilePaths *) final;
|
2019-10-22 14:55:51 +02:00
|
|
|
|
2021-07-14 16:49:42 +02:00
|
|
|
Utils::FilePaths filesGeneratedFrom(const Utils::FilePath &sourceFile) const final;
|
2021-09-09 11:28:28 +02:00
|
|
|
QString name() const final { return QLatin1String("cmake"); }
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
// Actions:
|
2019-10-25 09:55:32 +02:00
|
|
|
void runCMake();
|
|
|
|
|
void runCMakeAndScanProjectTree();
|
2020-04-02 14:49:05 +02:00
|
|
|
void runCMakeWithExtraArguments();
|
2021-12-22 15:18:00 +01:00
|
|
|
void stopCMakeRun();
|
2019-10-25 09:55:32 +02:00
|
|
|
|
|
|
|
|
bool persistCMakeState();
|
|
|
|
|
void clearCMakeCache();
|
|
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
// Context menu actions:
|
|
|
|
|
void buildCMakeTarget(const QString &buildTarget);
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
// Queries:
|
2019-10-25 09:55:32 +02:00
|
|
|
const QList<ProjectExplorer::BuildTargetInfo> appTargets() const;
|
|
|
|
|
QStringList buildTargetTitles() const;
|
|
|
|
|
const QList<CMakeBuildTarget> &buildTargets() const;
|
|
|
|
|
ProjectExplorer::DeploymentData deploymentData() const;
|
|
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
CMakeBuildConfiguration *cmakeBuildConfiguration() const;
|
|
|
|
|
|
2020-09-28 15:10:04 +02:00
|
|
|
QList<ProjectExplorer::TestCaseInfo> const testcasesInfo() const final;
|
|
|
|
|
Utils::CommandLine commandLineForTests(const QList<QString> &tests,
|
|
|
|
|
const QStringList &options) const final;
|
|
|
|
|
|
2022-06-10 16:41:27 +02:00
|
|
|
ProjectExplorer::MakeInstallCommand makeInstallCommand(
|
|
|
|
|
const Utils::FilePath &installRoot) const final;
|
|
|
|
|
|
2021-05-19 17:22:29 +02:00
|
|
|
static bool filteredOutTarget(const CMakeBuildTarget &target);
|
|
|
|
|
|
2021-01-14 16:38:55 +01:00
|
|
|
bool isMultiConfig() const;
|
2022-05-02 16:58:26 +02:00
|
|
|
void setIsMultiConfig(bool isMultiConfig);
|
|
|
|
|
|
|
|
|
|
bool isMultiConfigReader() const;
|
2021-01-14 16:38:55 +01:00
|
|
|
bool usesAllCapsTargets() const;
|
|
|
|
|
|
2021-09-21 22:22:37 +02:00
|
|
|
CMakeProject *project() const;
|
|
|
|
|
|
2022-05-02 18:02:37 +02:00
|
|
|
QString cmakeBuildType() const;
|
|
|
|
|
void setCMakeBuildType(const QString &cmakeBuildType, bool quiet = false);
|
|
|
|
|
ProjectExplorer::BuildConfiguration::BuildType buildType() const;
|
|
|
|
|
|
|
|
|
|
CMakeConfig configurationFromCMake() const;
|
|
|
|
|
CMakeConfig configurationChanges() const;
|
|
|
|
|
|
|
|
|
|
QStringList configurationChangesArguments(bool initialParameters = false) const;
|
|
|
|
|
|
|
|
|
|
QStringList initialCMakeArguments() const;
|
|
|
|
|
CMakeConfig initialCMakeConfiguration() const;
|
|
|
|
|
|
|
|
|
|
QStringList additionalCMakeArguments() const;
|
|
|
|
|
void setAdditionalCMakeArguments(const QStringList &args);
|
|
|
|
|
|
|
|
|
|
void filterConfigArgumentsFromAdditionalCMakeArguments();
|
|
|
|
|
|
|
|
|
|
void setConfigurationFromCMake(const CMakeConfig &config);
|
|
|
|
|
void setConfigurationChanges(const CMakeConfig &config);
|
|
|
|
|
|
|
|
|
|
void setInitialCMakeArguments(const QStringList &args);
|
|
|
|
|
|
2022-04-25 13:40:05 +02:00
|
|
|
QString error() const;
|
|
|
|
|
QString warning() const;
|
|
|
|
|
|
2021-12-28 21:42:29 +01:00
|
|
|
signals:
|
|
|
|
|
void configurationCleared();
|
2022-04-25 14:03:03 +02:00
|
|
|
void configurationChanged(const CMakeConfig &config);
|
|
|
|
|
void errorOccurred(const QString &message);
|
|
|
|
|
void warningOccurred(const QString &message);
|
2021-12-28 21:42:29 +01:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
private:
|
2022-12-06 17:07:52 +01:00
|
|
|
QList<QPair<Utils::Id, QString>> generators() const override;
|
|
|
|
|
void runGenerator(Utils::Id id) override;
|
|
|
|
|
|
2022-04-25 13:40:05 +02:00
|
|
|
enum ForceEnabledChanged { False, True };
|
|
|
|
|
void clearError(ForceEnabledChanged fec = ForceEnabledChanged::False);
|
|
|
|
|
|
|
|
|
|
void setError(const QString &message);
|
|
|
|
|
void setWarning(const QString &message);
|
|
|
|
|
|
2020-04-24 10:29:43 +02:00
|
|
|
// Actually ask for parsing:
|
|
|
|
|
enum ReparseParameters {
|
2020-04-02 14:49:05 +02:00
|
|
|
REPARSE_DEFAULT = 0, // Nothing special:-)
|
|
|
|
|
REPARSE_FORCE_CMAKE_RUN
|
|
|
|
|
= (1 << 0), // Force cmake to run, apply extraCMakeArguments if non-empty
|
|
|
|
|
REPARSE_FORCE_INITIAL_CONFIGURATION
|
|
|
|
|
= (1 << 1), // Force initial configuration arguments to cmake
|
|
|
|
|
REPARSE_FORCE_EXTRA_CONFIGURATION = (1 << 2), // Force extra configuration arguments to cmake
|
2021-09-27 17:26:40 +02:00
|
|
|
REPARSE_URGENT = (1 << 3), // Do not delay the parser run by 1s
|
2020-04-24 10:29:43 +02:00
|
|
|
};
|
2022-05-05 15:28:09 +02:00
|
|
|
void reparse(int reparseParameters);
|
2020-04-24 10:29:43 +02:00
|
|
|
QString reparseParametersString(int reparseFlags);
|
|
|
|
|
void setParametersAndRequestParse(const BuildDirParameters ¶meters,
|
|
|
|
|
const int reparseParameters);
|
|
|
|
|
|
2021-12-28 21:42:29 +01:00
|
|
|
bool mustApplyConfigurationChangesArguments(const BuildDirParameters ¶meters) const;
|
2020-04-24 10:29:43 +02:00
|
|
|
|
|
|
|
|
// State handling:
|
2020-04-23 18:29:27 +02:00
|
|
|
// Parser states:
|
|
|
|
|
void handleParsingSuccess();
|
|
|
|
|
void handleParsingError();
|
|
|
|
|
|
|
|
|
|
// Treescanner states:
|
|
|
|
|
void handleTreeScanningFinished();
|
2019-08-06 12:41:46 +02:00
|
|
|
|
|
|
|
|
// Combining Treescanner and Parser states:
|
2021-09-21 22:22:37 +02:00
|
|
|
void combineScanAndParse(bool restoredFromBackup);
|
2019-10-25 09:55:32 +02:00
|
|
|
void checkAndReportError(QString &errorMessage);
|
|
|
|
|
|
2021-02-04 16:22:40 +01:00
|
|
|
void updateCMakeConfiguration(QString &errorMessage);
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void updateProjectData();
|
2020-10-26 15:36:59 +01:00
|
|
|
void updateFallbackProjectData();
|
2019-10-25 09:55:32 +02:00
|
|
|
QList<ProjectExplorer::ExtraCompiler *> findExtraCompilers();
|
2021-03-17 11:38:33 +01:00
|
|
|
void updateQmlJSCodeModel(const QStringList &extraHeaderPaths,
|
|
|
|
|
const QList<QByteArray> &moduleMappings);
|
2021-04-15 22:48:23 +02:00
|
|
|
void updateInitialCMakeExpandableVars();
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2021-09-27 17:26:40 +02:00
|
|
|
void updateFileSystemNodes();
|
|
|
|
|
|
2021-09-21 22:22:37 +02:00
|
|
|
void handleParsingSucceeded(bool restoredFromBackup);
|
2019-10-25 09:55:32 +02:00
|
|
|
void handleParsingFailed(const QString &msg);
|
|
|
|
|
|
2020-08-11 16:36:24 +02:00
|
|
|
void wireUpConnections();
|
2020-04-20 17:33:36 +02:00
|
|
|
|
2022-05-20 14:11:52 +02:00
|
|
|
void ensureBuildDirectory(const BuildDirParameters ¶meters);
|
2020-04-24 10:29:43 +02:00
|
|
|
void stopParsingAndClearState();
|
|
|
|
|
void becameDirty();
|
|
|
|
|
|
|
|
|
|
void updateReparseParameters(const int parameters);
|
|
|
|
|
int takeReparseParameters();
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2020-09-28 15:10:04 +02:00
|
|
|
void runCTest();
|
|
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
ProjectExplorer::TreeScanner m_treeScanner;
|
2021-09-27 17:26:40 +02:00
|
|
|
std::shared_ptr<ProjectExplorer::FolderNode> m_allFiles;
|
2019-08-06 12:41:46 +02:00
|
|
|
QHash<QString, bool> m_mimeBinaryCache;
|
|
|
|
|
|
|
|
|
|
bool m_waitingForParse = false;
|
|
|
|
|
bool m_combinedScanAndParseResult = false;
|
|
|
|
|
|
2022-05-02 16:58:26 +02:00
|
|
|
bool m_isMultiConfig = false;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
ParseGuard m_currentGuard;
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
CppEditor::CppProjectUpdater *m_cppCodeModelUpdater = nullptr;
|
2019-08-06 12:41:46 +02:00
|
|
|
QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers;
|
2019-10-25 09:55:32 +02:00
|
|
|
QList<CMakeBuildTarget> m_buildTargets;
|
2020-04-24 10:29:43 +02:00
|
|
|
|
|
|
|
|
// Parsing state:
|
|
|
|
|
BuildDirParameters m_parameters;
|
2020-04-02 14:49:05 +02:00
|
|
|
int m_reparseParameters = REPARSE_DEFAULT;
|
2020-04-24 10:29:43 +02:00
|
|
|
FileApiReader m_reader;
|
|
|
|
|
mutable bool m_isHandlingError = false;
|
2020-09-28 15:10:04 +02:00
|
|
|
|
|
|
|
|
// CTest integration
|
2021-08-10 16:19:02 +02:00
|
|
|
Utils::FilePath m_ctestPath;
|
2023-01-12 23:32:11 +01:00
|
|
|
std::unique_ptr<Utils::QtcProcess> m_ctestProcess;
|
2020-09-28 15:10:04 +02:00
|
|
|
QList<ProjectExplorer::TestCaseInfo> m_testNames;
|
2022-04-25 13:40:05 +02:00
|
|
|
|
2022-05-02 18:02:37 +02:00
|
|
|
CMakeConfig m_configurationFromCMake;
|
|
|
|
|
CMakeConfig m_configurationChanges;
|
|
|
|
|
|
2022-04-25 13:40:05 +02:00
|
|
|
QString m_error;
|
|
|
|
|
QString m_warning;
|
2019-08-06 12:41:46 +02:00
|
|
|
};
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
} // namespace Internal
|
2019-08-06 12:41:46 +02:00
|
|
|
} // namespace CMakeProjectManager
|