diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 71dac7a96a2..108a94716ec 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -2109,6 +2109,35 @@ const QList CMakeBuildSystem::appTargets() const env.prependOrSetLibrarySearchPaths(librarySearchPaths(this, buildKey)); }; + appTargetList.append(bti); + } else if (ct.targetType == UtilityType && ct.qtcRunnable) { + const QString buildKey = ct.title; + CMakeTool *cmakeTool = CMakeKitAspect::cmakeTool(target()->kit()); + if (!cmakeTool) + continue; + + // Skip the "all", "clean", "install" special targets. + if (CMakeBuildStep::specialTargets(m_reader.usesAllCapsTargets()).contains(buildKey)) + continue; + + BuildTargetInfo bti; + bti.displayName = ct.title; + + // We need the build directory, which is proper set to the "clean" target + // and "clean" doesn't differ between single and multi-config generators + const FilePath workingDirectory + = Utils::findOrDefault(m_buildTargets, [](const CMakeBuildTarget &bt) { + return bt.title == "clean"; + }).workingDirectory; + + bti.targetFilePath = cmakeTool->cmakeExecutable(); + bti.projectFilePath = ct.sourceDirectory.cleanPath(); + bti.workingDirectory = workingDirectory; + bti.buildKey = buildKey; + bti.isQtcRunnable = ct.qtcRunnable; + bti.additionalData = QVariantMap{ + {"arguments", QStringList{"--build", ".", "--target", buildKey}}}; + appTargetList.append(bti); } } diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp index 41e98941ab2..bf090a8711d 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp @@ -263,6 +263,9 @@ static CMakeBuildTarget toBuildTarget(const TargetDetails &t, ct.sourceFiles.append(sourceDirectory.resolvePath(si.path)); } + // FIXME: remove the usage of "qtc_runnable" by parsing the CMake code instead + ct.qtcRunnable = t.folderTargetProperty == QTC_RUNNABLE; + if (ct.targetType == ExecutableType) { FilePaths librarySeachPaths; // Is this a GUI application? @@ -272,9 +275,6 @@ static CMakeBuildTarget toBuildTarget(const TargetDetails &t, || f.fragment.contains("Qt6Gui")); }); - // FIXME: remove the usage of "qtc_runnable" by parsing the CMake code instead - ct.qtcRunnable = t.folderTargetProperty == QTC_RUNNABLE; - // Extract library directories for executables: for (const FragmentInfo &f : t.link->fragments) { if (f.role == "flags") // ignore all flags fragments diff --git a/src/plugins/projectexplorer/desktoprunconfiguration.cpp b/src/plugins/projectexplorer/desktoprunconfiguration.cpp index b3545746d8e..83a6a87dbc6 100644 --- a/src/plugins/projectexplorer/desktoprunconfiguration.cpp +++ b/src/plugins/projectexplorer/desktoprunconfiguration.cpp @@ -143,8 +143,14 @@ void DesktopRunConfiguration::updateTargetInformation() } aspect()->setExecutable(bti.targetFilePath); aspect()->setDefaultWorkingDirectory(bti.workingDirectory); - emit aspect()->environmentChanged(); + auto argumentsAsString = [bti]() { + return CommandLine{"", bti.additionalData.toMap()["arguments"].toStringList()} + .arguments(); + }; + aspect()->setArguments(argumentsAsString()); + + emit aspect()->environmentChanged(); } }