forked from qt-creator/qt-creator
CMake: Do not treat project with the empty string as a name as invalid
CMake will happily accept the empty string as a project name, so do not treat that is invalid in Creator. Apparently the empty project name will get generated by CMake itself if no project() command is found in the top level CMakeLists.txt file. Make sure to set a sensible name if the top-level project has no name, using the directory name of the source directory instead. Change-Id: I3b861daa13c1d0fec31c294ef0ac15338310020d Fixes: QTCREATORBUG-24044 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -581,6 +581,8 @@ std::pair<std::unique_ptr<CMakeProjectNode>, QSet<FilePath>> generateRootProject
|
|||||||
= findOrDefault(data.codemodel.projects, equal(&FileApiDetails::Project::parent, -1));
|
= findOrDefault(data.codemodel.projects, equal(&FileApiDetails::Project::parent, -1));
|
||||||
if (!topLevelProject.name.isEmpty())
|
if (!topLevelProject.name.isEmpty())
|
||||||
result.first->setDisplayName(topLevelProject.name);
|
result.first->setDisplayName(topLevelProject.name);
|
||||||
|
else
|
||||||
|
result.first->setDisplayName(sourceDirectory.fileName());
|
||||||
|
|
||||||
QHash<FilePath, ProjectNode *> cmakeListsNodes = addCMakeLists(result.first.get(),
|
QHash<FilePath, ProjectNode *> cmakeListsNodes = addCMakeLists(result.first.get(),
|
||||||
std::move(data.cmakeListNodes));
|
std::move(data.cmakeListNodes));
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ static std::vector<Project> extractProjects(const QJsonArray &projects, QString
|
|||||||
|
|
||||||
qCDebug(cmakeFileApi) << "Project read:" << project.name << project.directories;
|
qCDebug(cmakeFileApi) << "Project read:" << project.name << project.directories;
|
||||||
|
|
||||||
if (project.name.isEmpty() || project.directories.empty()) {
|
if (project.directories.empty()) {
|
||||||
errorMessage = QCoreApplication::translate(
|
errorMessage = QCoreApplication::translate(
|
||||||
"CMakeProjectManager::Internal",
|
"CMakeProjectManager::Internal",
|
||||||
"Invalid codemodel file generated by CMake: Broken project data.");
|
"Invalid codemodel file generated by CMake: Broken project data.");
|
||||||
|
|||||||
Reference in New Issue
Block a user