CMakePM: Add support for qtc_runnable feature

This will allow for the Qt Creator's CMake build only qtcreator
target to be selected as runnable.

Similar to qmake's qtc_runnable or Qbs's qtcRunnable features.

Fixes: QTCREATORBUG-25908
Change-Id: I6416873d0ad9cfec4960d98fc4b289ec98cc58b1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2021-06-24 17:44:14 +02:00
parent 6d26f4f5b0
commit f8a77287bf
5 changed files with 11 additions and 1 deletions

View File

@@ -602,7 +602,7 @@ function(extend_qtc_test target_name)
endfunction()
function(add_qtc_executable name)
cmake_parse_arguments(_arg "SKIP_INSTALL;SKIP_TRANSLATION;ALLOW_ASCII_CASTS;SKIP_PCH"
cmake_parse_arguments(_arg "SKIP_INSTALL;SKIP_TRANSLATION;ALLOW_ASCII_CASTS;SKIP_PCH;QTC_RUNNABLE"
"DESTINATION;COMPONENT;BUILD_DEFAULT"
"CONDITION;DEPENDS;DEFINES;INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;EXTRA_TRANSLATIONS;PROPERTIES" ${ARGN})
@@ -707,6 +707,11 @@ function(add_qtc_executable name)
enable_pch(${name})
endif()
if (_arg_QTC_RUNNABLE)
# Used by QtCreator to select the default target in the project
set_target_properties(${name} PROPERTIES FOLDER "qtc_runnable")
endif()
if (NOT _arg_SKIP_INSTALL)
unset(COMPONENT_OPTION)
if (_arg_COMPONENT)

View File

@@ -17,6 +17,7 @@ add_qtc_executable(qtcreator
MACOSX_BUNDLE ON
OUTPUT_NAME "${IDE_APP_TARGET}"
DESTINATION "${IDE_APP_PATH}"
QTC_RUNNABLE
)
if (NOT TARGET qtcreator)

View File

@@ -1009,6 +1009,7 @@ const QList<BuildTargetInfo> CMakeBuildSystem::appTargets() const
bti.workingDirectory = ct.workingDirectory;
bti.buildKey = buildKey;
bti.usesTerminal = !ct.linksToQtGui;
bti.isQtcRunnable = ct.qtcRunnable;
// Workaround for QTCREATORBUG-19354:
bti.runEnvModifier = [this, buildKey](Environment &env, bool enabled) {

View File

@@ -54,6 +54,7 @@ public:
Utils::FilePath executable; // TODO: rename to output?
TargetType targetType = UtilityType;
bool linksToQtGui = false;
bool qtcRunnable = true;
Utils::FilePath workingDirectory;
Utils::FilePath sourceDirectory;
Utils::FilePath makeCommand;

View File

@@ -256,6 +256,8 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
|| f.fragment.contains("Qt6Gui"));
});
ct.qtcRunnable = t.folderTargetProperty == "qtc_runnable";
// Extract library directories for executables:
for (const FragmentInfo &f : t.link.value().fragments) {
if (f.role == "flags") // ignore all flags fragments