From 3b86d90266d2968d0dff64dd64582e62fc1bee67 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 23 Nov 2017 14:06:48 +0100 Subject: [PATCH] CMake: Add QT_INSTALL_BINS to PATH on windows Add QT_INSTALL_BINS to PATH on windows in the CMake RunConfiguration. This should fix cmake applications using Qt not being able to get started after they were built. Unfortunately this patch is not a great solution: This should be configurable, similar to the "Add libraries to LD_LIBRARY_PATH" checkbox we have for other OSes and build systems. Such a change is unfortunately not acceptable at this stage of the 4.5 branch though. Task-number: QTCREATORBUG-19354 Change-Id: Ic2d568d965e41e3eb875fed8c2e5dd2ba15d2db1 Reviewed-by: Eike Ziller --- .../cmakeprojectmanager/cmakerunconfiguration.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 67823d4b68f..64d487aeb4e 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -64,7 +65,17 @@ const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title"; CMakeRunConfiguration::CMakeRunConfiguration(Target *target) : RunConfiguration(target) { - addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier())); + // Workaround for QTCREATORBUG-19354: + auto cmakeRunEnvironmentModifier = [](RunConfiguration *rc, Utils::Environment &env) { + if (!Utils::HostOsInfo::isWindowsHost() || !rc) + return; + + const Kit *k = rc->target()->kit(); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(k); + if (qt) + env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS")); + }; + addExtraAspect(new LocalEnvironmentAspect(this, cmakeRunEnvironmentModifier)); addExtraAspect(new ArgumentsAspect(this, "CMakeProjectManager.CMakeRunConfiguration.Arguments")); addExtraAspect(new TerminalAspect(this, "CMakeProjectManager.CMakeRunConfiguration.UseTerminal")); addExtraAspect(new WorkingDirectoryAspect(this, "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"));