forked from qt-creator/qt-creator
CMakePM: Refactor CMakeLists|Cache.txt as constants
Change-Id: I7165fa1d219a0c59bc519a9af1cd194414c4311c Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "cmakeabstractprocessstep.h"
|
||||
|
||||
#include "cmakekitaspect.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmaketool.h"
|
||||
|
||||
@@ -50,7 +51,7 @@ bool CMakeAbstractProcessStep::init()
|
||||
// Warn if doing out-of-source builds with a CMakeCache.txt is the source directory
|
||||
const Utils::FilePath projectDirectory = bc->target()->project()->projectDirectory();
|
||||
if (bc->buildDirectory() != projectDirectory) {
|
||||
if (projectDirectory.pathAppended("CMakeCache.txt").exists()) {
|
||||
if (projectDirectory.pathAppended(Constants::CMAKE_CACHE_TXT).exists()) {
|
||||
emit addTask(BuildSystemTask(
|
||||
Task::Warning,
|
||||
Tr::tr("There is a CMakeCache.txt file in \"%1\", which suggest an "
|
||||
|
||||
@@ -853,7 +853,8 @@ CMakeConfig CMakeBuildSettingsWidget::getQmlDebugCxxFlags()
|
||||
CMakeConfig changedConfig;
|
||||
|
||||
if (enable) {
|
||||
const FilePath cmakeCache = m_buildConfig->buildDirectory().pathAppended("CMakeCache.txt");
|
||||
const FilePath cmakeCache = m_buildConfig->buildDirectory().pathAppended(
|
||||
Constants::CMAKE_CACHE_TXT);
|
||||
|
||||
// Only modify the CMAKE_CXX_FLAGS variable if the project was previously configured
|
||||
// otherwise CMAKE_CXX_FLAGS_INIT will take care of setting the qmlDebug define
|
||||
@@ -1349,8 +1350,10 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
|
||||
if (oldDir.isEmpty())
|
||||
return newDir;
|
||||
|
||||
const FilePath oldDirCMakeCache = FilePath::fromUserInput(oldDir).pathAppended("CMakeCache.txt");
|
||||
const FilePath newDirCMakeCache = FilePath::fromUserInput(newDir).pathAppended("CMakeCache.txt");
|
||||
const FilePath oldDirCMakeCache = FilePath::fromUserInput(oldDir).pathAppended(
|
||||
Constants::CMAKE_CACHE_TXT);
|
||||
const FilePath newDirCMakeCache = FilePath::fromUserInput(newDir).pathAppended(
|
||||
Constants::CMAKE_CACHE_TXT);
|
||||
|
||||
if (oldDirCMakeCache.exists() && !newDirCMakeCache.exists()) {
|
||||
if (QMessageBox::information(
|
||||
@@ -2048,7 +2051,8 @@ QString CMakeBuildSystem::cmakeBuildType() const
|
||||
|
||||
QString cmakeBuildType = cmakeBuildConfiguration()->buildTypeAspect();
|
||||
|
||||
const Utils::FilePath cmakeCacheTxt = buildConfiguration()->buildDirectory().pathAppended("CMakeCache.txt");
|
||||
const Utils::FilePath cmakeCacheTxt = buildConfiguration()->buildDirectory().pathAppended(
|
||||
Constants::CMAKE_CACHE_TXT);
|
||||
const bool hasCMakeCache = cmakeCacheTxt.exists();
|
||||
CMakeConfig config;
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ void CMakeBuildSystem::triggerParsing()
|
||||
qCDebug(cmakeBuildSystemLog) << "Parse called with flags:"
|
||||
<< reparseParametersString(reparseParameters);
|
||||
|
||||
const FilePath cache = m_parameters.buildDirectory.pathAppended("CMakeCache.txt");
|
||||
const FilePath cache = m_parameters.buildDirectory.pathAppended(Constants::CMAKE_CACHE_TXT);
|
||||
if (!cache.exists()) {
|
||||
reparseParameters |= REPARSE_FORCE_INITIAL_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN;
|
||||
qCDebug(cmakeBuildSystemLog)
|
||||
@@ -973,7 +973,7 @@ FilePaths CMakeBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const
|
||||
FilePath baseDirectory = sourceFile.parentDir();
|
||||
|
||||
while (baseDirectory.isChildOf(project)) {
|
||||
const FilePath cmakeListsTxt = baseDirectory.pathAppended("CMakeLists.txt");
|
||||
const FilePath cmakeListsTxt = baseDirectory.pathAppended(Constants::CMAKE_LISTS_TXT);
|
||||
if (cmakeListsTxt.exists())
|
||||
break;
|
||||
baseDirectory = baseDirectory.parentDir();
|
||||
@@ -1178,8 +1178,8 @@ void CMakeBuildSystem::clearCMakeCache()
|
||||
stopParsingAndClearState();
|
||||
|
||||
const FilePath pathsToDelete[] = {
|
||||
m_parameters.buildDirectory / "CMakeCache.txt",
|
||||
m_parameters.buildDirectory / "CMakeCache.txt.prev",
|
||||
m_parameters.buildDirectory / Constants::CMAKE_CACHE_TXT,
|
||||
m_parameters.buildDirectory / Constants::CMAKE_CACHE_TXT_PREV,
|
||||
m_parameters.buildDirectory / "CMakeFiles",
|
||||
m_parameters.buildDirectory / ".cmake/api/v1/reply",
|
||||
m_parameters.buildDirectory / ".cmake/api/v1/reply.prev",
|
||||
@@ -1601,7 +1601,8 @@ void CMakeBuildSystem::wireUpConnections()
|
||||
// No CMakeCache? Run with initial arguments!
|
||||
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to build directory change";
|
||||
const BuildDirParameters parameters(this);
|
||||
const FilePath cmakeCacheTxt = parameters.buildDirectory.pathAppended("CMakeCache.txt");
|
||||
const FilePath cmakeCacheTxt = parameters.buildDirectory.pathAppended(
|
||||
Constants::CMAKE_CACHE_TXT);
|
||||
const bool hasCMakeCache = cmakeCacheTxt.exists();
|
||||
const auto options = ReparseParameters(
|
||||
hasCMakeCache
|
||||
|
||||
@@ -398,7 +398,7 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||
fileName = dir.pathAppended(fileName.path());
|
||||
if (fileName.exists()) {
|
||||
if (fileName.isDir()) {
|
||||
Utils::FilePath subProject = fileName.pathAppended("CMakeLists.txt");
|
||||
Utils::FilePath subProject = fileName.pathAppended(Constants::CMAKE_LISTS_TXT);
|
||||
if (subProject.exists())
|
||||
fileName = subProject;
|
||||
else
|
||||
|
||||
@@ -82,7 +82,7 @@ CMakeFileCompletionAssist::CMakeFileCompletionAssist()
|
||||
Icon::MenuTintedStyle)
|
||||
.icon())
|
||||
, m_snippetCollector(Constants::CMAKE_SNIPPETS_GROUP_ID,
|
||||
FileIconProvider::icon(FilePath::fromString("CMakeLists.txt")))
|
||||
FileIconProvider::icon(FilePath::fromString(Constants::CMAKE_LISTS_TXT)))
|
||||
{}
|
||||
|
||||
static bool isInComment(const AssistInterface *interface)
|
||||
|
||||
@@ -27,6 +27,10 @@ const char CMAKE_DEBUGGING_GROUP[] = "Debugger.Group.CMake";
|
||||
|
||||
const char PACKAGE_MANAGER_DIR[] = ".qtc/package-manager";
|
||||
|
||||
const char CMAKE_LISTS_TXT[] = "CMakeLists.txt";
|
||||
const char CMAKE_CACHE_TXT[] = "CMakeCache.txt";
|
||||
const char CMAKE_CACHE_TXT_PREV[] = "CMakeCache.txt.prev";
|
||||
|
||||
// Project
|
||||
const char CMAKE_PROJECT_ID[] = "CMakeProjectManager.CMakeProject";
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ static CMakeConfig configurationFromPresetProbe(
|
||||
const FilePath &sourceDirectory,
|
||||
const PresetsDetails::ConfigurePreset &configurePreset)
|
||||
{
|
||||
const FilePath cmakeListTxt = importPath / "CMakeLists.txt";
|
||||
const FilePath cmakeListTxt = importPath / Constants::CMAKE_LISTS_TXT;
|
||||
cmakeListTxt.writeFileContents(QByteArray("cmake_minimum_required(VERSION 3.15)\n"
|
||||
"\n"
|
||||
"project(preset-probe)\n"
|
||||
@@ -358,7 +358,7 @@ static QMakeAndCMakePrefixPath qtInfoFromCMakeCache(const CMakeConfig &config,
|
||||
// Run a CMake project that would do qmake probing
|
||||
TemporaryDirectory qtcQMakeProbeDir("qtc-cmake-qmake-probe-XXXXXXXX");
|
||||
|
||||
FilePath cmakeListTxt(qtcQMakeProbeDir.filePath("CMakeLists.txt"));
|
||||
FilePath cmakeListTxt(qtcQMakeProbeDir.filePath(Constants::CMAKE_LISTS_TXT));
|
||||
|
||||
cmakeListTxt.writeFileContents(QByteArray(R"(
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
@@ -829,7 +829,7 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
|
||||
return result;
|
||||
}
|
||||
|
||||
const FilePath cacheFile = importPath.pathAppended("CMakeCache.txt");
|
||||
const FilePath cacheFile = importPath.pathAppended(Constants::CMAKE_CACHE_TXT);
|
||||
|
||||
if (!cacheFile.exists()) {
|
||||
qCDebug(cmInputLog) << cacheFile.toUserOutput() << "does not exist, returning.";
|
||||
|
||||
@@ -53,7 +53,7 @@ bool CMakeListsNode::showInSimpleTree() const
|
||||
|
||||
std::optional<FilePath> CMakeListsNode::visibleAfterAddFileAction() const
|
||||
{
|
||||
return filePath().pathAppended("CMakeLists.txt");
|
||||
return filePath().pathAppended(Constants::CMAKE_LISTS_TXT);
|
||||
}
|
||||
|
||||
CMakeProjectNode::CMakeProjectNode(const FilePath &directory) :
|
||||
@@ -189,7 +189,7 @@ void CMakeTargetNode::setConfig(const CMakeConfig &config)
|
||||
|
||||
std::optional<FilePath> CMakeTargetNode::visibleAfterAddFileAction() const
|
||||
{
|
||||
return filePath().pathAppended("CMakeLists.txt");
|
||||
return filePath().pathAppended(Constants::CMAKE_LISTS_TXT);
|
||||
}
|
||||
|
||||
void CMakeTargetNode::build()
|
||||
|
||||
@@ -93,7 +93,7 @@ class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
||||
|
||||
FileIconProvider::registerIconOverlayForSuffix(Constants::Icons::FILE_OVERLAY, "cmake");
|
||||
FileIconProvider::registerIconOverlayForFilename(Constants::Icons::FILE_OVERLAY,
|
||||
"CMakeLists.txt");
|
||||
Constants::CMAKE_LISTS_TXT);
|
||||
|
||||
TextEditor::SnippetProvider::registerGroup(Constants::CMAKE_SNIPPETS_GROUP_ID,
|
||||
Tr::tr("CMake", "SnippetProvider"));
|
||||
|
||||
@@ -415,7 +415,8 @@ static RawProjectParts generateRawProjectParts(const QFuture<void> &cancelFuture
|
||||
}
|
||||
|
||||
RawProjectPart rpp;
|
||||
rpp.setProjectFileLocation(t.sourceDir.pathAppended("CMakeLists.txt").toString());
|
||||
rpp.setProjectFileLocation(
|
||||
t.sourceDir.pathAppended(Constants::CMAKE_LISTS_TXT).toString());
|
||||
rpp.setBuildSystemTarget(t.name);
|
||||
const QString postfix = needPostfix ? QString("_%1_%2").arg(ci.language).arg(count)
|
||||
: QString();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "fileapiparser.h"
|
||||
|
||||
#include "cmakeprocess.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
|
||||
#include <coreplugin/messagemanager.h>
|
||||
@@ -230,7 +231,7 @@ static std::vector<CMakeFileInfo> readCMakeFilesFile(const FilePath &cmakeFilesF
|
||||
|
||||
info.isCMake = input.value("isCMake").toBool();
|
||||
const QString filename = info.path.fileName();
|
||||
info.isCMakeListsDotTxt = (filename.compare("CMakeLists.txt",
|
||||
info.isCMakeListsDotTxt = (filename.compare(Constants::CMAKE_LISTS_TXT,
|
||||
HostOsInfo::fileNameCaseSensitivity())
|
||||
== 0);
|
||||
|
||||
@@ -860,7 +861,7 @@ FileApiData FileApiParser::parseData(QPromise<std::shared_ptr<FileApiQtcData>> &
|
||||
return {};
|
||||
const FilePath cachePathFromReply = result.replyFile.jsonFile("cache", replyDir);
|
||||
if (cachePathFromReply.isEmpty())
|
||||
result.cache = CMakeConfig::fromFile(buildDir / "CMakeCache.txt", &errorMessage);
|
||||
result.cache = CMakeConfig::fromFile(buildDir / Constants::CMAKE_CACHE_TXT, &errorMessage);
|
||||
else
|
||||
result.cache = readCacheFile(cachePathFromReply, errorMessage);
|
||||
if (cancelCheck())
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "cmakeprocess.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "fileapidataextractor.h"
|
||||
#include "fileapiparser.h"
|
||||
@@ -73,7 +74,7 @@ void FileApiReader::resetData()
|
||||
m_cmakeFiles.clear();
|
||||
if (!m_parameters.sourceDirectory.isEmpty()) {
|
||||
CMakeFileInfo cmakeListsTxt;
|
||||
cmakeListsTxt.path = m_parameters.sourceDirectory.pathAppended("CMakeLists.txt");
|
||||
cmakeListsTxt.path = m_parameters.sourceDirectory.pathAppended(Constants::CMAKE_LISTS_TXT);
|
||||
cmakeListsTxt.isCMakeListsDotTxt = true;
|
||||
m_cmakeFiles.insert(cmakeListsTxt);
|
||||
}
|
||||
@@ -316,8 +317,8 @@ void FileApiReader::makeBackupConfiguration(bool store)
|
||||
.arg(reply.toString(), replyPrev.toString())));
|
||||
}
|
||||
|
||||
FilePath cmakeCacheTxt = m_parameters.buildDirectory.pathAppended("CMakeCache.txt");
|
||||
FilePath cmakeCacheTxtPrev = m_parameters.buildDirectory.pathAppended("CMakeCache.txt.prev");
|
||||
FilePath cmakeCacheTxt = m_parameters.buildDirectory.pathAppended(Constants::CMAKE_CACHE_TXT);
|
||||
FilePath cmakeCacheTxtPrev = m_parameters.buildDirectory.pathAppended(Constants::CMAKE_CACHE_TXT_PREV);
|
||||
if (!store)
|
||||
std::swap(cmakeCacheTxt, cmakeCacheTxtPrev);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "projecttreehelper.h"
|
||||
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -98,7 +99,7 @@ void addCMakePresets(FolderNode *root, const Utils::FilePath &sourceDir)
|
||||
presetFileNames << "CMakeUserPresets.json";
|
||||
|
||||
const CMakeProject *cp = static_cast<const CMakeProject *>(
|
||||
ProjectManager::projectForFile(sourceDir.pathAppended("CMakeLists.txt")));
|
||||
ProjectManager::projectForFile(sourceDir.pathAppended(Constants::CMAKE_LISTS_TXT)));
|
||||
|
||||
if (cp && cp->presetsData().include)
|
||||
presetFileNames.append(cp->presetsData().include.value());
|
||||
|
||||
Reference in New Issue
Block a user