MCPcopy Create free account
hub / github.com/KDE/kdevelop / checkForNeedingConfigure

Function checkForNeedingConfigure

plugins/cmake/cmakeutils.cpp:135–209  ·  view source on GitHub ↗

NOTE: when you change this, update @c defaultConfigure in cmakemanagertest.cpp

Source from the content-addressed store, hash-verified

133
134///NOTE: when you change this, update @c defaultConfigure in cmakemanagertest.cpp
135bool checkForNeedingConfigure( KDevelop::IProject* project )
136{
137 auto currentRuntime = ICore::self()->runtimeController()->currentRuntime();
138 const QString currentRuntimeName = currentRuntime->name();
139 const KDevelop::Path builddir = currentBuildDir(project);
140 const bool isValid = (buildDirRuntime(project, -1) == currentRuntimeName || buildDirRuntime(project, -1).isEmpty()) && builddir.isValid();
141
142 if( !isValid )
143 {
144 auto addBuildDir = [project](const KDevelop::Path& buildFolder, const KDevelop::Path& installPrefix, const QString &extraArguments, const QString &buildType, const KDevelop::Path &cmakeExecutable){
145 int addedBuildDirIndex = buildDirCount( project ); // old count is the new index
146
147 // Initialize the kconfig items with the values from the dialog, this ensures the settings
148 // end up in the config file once the changes are saved
149 qCDebug(CMAKE) << "adding to cmake config: new builddir index" << addedBuildDirIndex;
150 qCDebug(CMAKE) << "adding to cmake config: builddir path " << buildFolder;
151 qCDebug(CMAKE) << "adding to cmake config: installdir " << installPrefix;
152 qCDebug(CMAKE) << "adding to cmake config: extra args" << extraArguments;
153 qCDebug(CMAKE) << "adding to cmake config: build type " << buildType;
154 qCDebug(CMAKE) << "adding to cmake config: cmake executable " << cmakeExecutable;
155 qCDebug(CMAKE) << "adding to cmake config: environment <null>";
156 CMake::setBuildDirCount( project, addedBuildDirIndex + 1 );
157 CMake::setCurrentBuildDirIndex( project, addedBuildDirIndex );
158 CMake::setCurrentBuildDir( project, buildFolder );
159 CMake::setCurrentInstallDir( project, installPrefix );
160 CMake::setCurrentExtraArguments( project, extraArguments );
161 CMake::setCurrentBuildType( project, buildType );
162 CMake::setCurrentCMakeExecutable(project, cmakeExecutable );
163 CMake::setCurrentEnvironment( project, QString() );
164 };
165
166 if (!currentRuntime->buildPath().isEmpty()) {
167 const Path newBuilddir(currentRuntime->buildPath(), QLatin1String("build-") + currentRuntimeName + project->name());
168 const Path installPath(QString::fromUtf8(currentRuntime->getenv("KDEV_DEFAULT_INSTALL_PREFIX")));
169
170 addBuildDir(newBuilddir, installPath, {}, QStringLiteral("Debug"), {});
171 setBuildDirRuntime( project, currentRuntimeName );
172 return true;
173 }
174
175 CMakeBuildDirChooser bd;
176 bd.setProject( project );
177 const auto builddirs = CMake::allBuildDirs(project);
178 bd.setAlreadyUsed( builddirs );
179 bd.setShowAvailableBuildDirs(!builddirs.isEmpty());
180 bd.setCMakeExecutable(currentCMakeExecutable(project));
181
182 if( !bd.exec() )
183 {
184 return false;
185 }
186
187 if (bd.reuseBuilddir())
188 {
189 CMake::setCurrentBuildDirIndex( project, bd.alreadyUsedIndex() );
190 }
191 else
192 {

Callers 5

importMethod · 0.85
checkConfigureJobMethod · 0.85
importMethod · 0.85
reloadProjectsMethod · 0.85

Calls 15

currentBuildDirFunction · 0.85
buildDirRuntimeFunction · 0.85
buildDirCountFunction · 0.85
setBuildDirCountFunction · 0.85
setCurrentBuildDirIndexFunction · 0.85
setCurrentBuildDirFunction · 0.85
setCurrentInstallDirFunction · 0.85
setCurrentExtraArgumentsFunction · 0.85
setCurrentBuildTypeFunction · 0.85
setCurrentEnvironmentFunction · 0.85
setBuildDirRuntimeFunction · 0.85

Tested by

no test coverage detected