From 45ec26783f484a3138de6be6c4e36e658b3f94fd Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 13 Oct 2022 15:45:40 +0200 Subject: [PATCH] CMakePM: Search after ninja also in system environment CMakePM was setting the default generator to Ninja if the ninja executable was set in the build environment. This had the side effect of having to instantiate the build environment for Visual C++, which meant running vcvars.bat files. This operation can be costly if clink is also installed in the system. This way the users that have ninja installed via choco, or manually set it path, will not be affected by this delay. Note that this only fixes the issue for the first start of Qt Creator with new settings. Some number from my machine: - with clink 21s - without clink 10s - with this patchset 4s Task-number: QTCREATORBUG-27906 Change-Id: I74d19b08211d93b3962a8877b49a58089310fbd6 Reviewed-by: Cristian Adam --- src/plugins/cmakeprojectmanager/cmakekitinformation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp index 42eccdf7e06..523bafca68d 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp @@ -682,8 +682,11 @@ QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const = Internal::CMakeProjectPlugin::projectTypeSpecificSettings(); if (settings->ninjaPath.filePath().isEmpty()) { - Environment env = k->buildEnvironment(); - return !env.searchInPath("ninja").isEmpty(); + auto findNinja = [](const Environment &env) -> bool { + return !env.searchInPath("ninja").isEmpty(); + }; + if (!findNinja(Environment::systemEnvironment())) + return findNinja(k->buildEnvironment()); } return true; }();