MCPcopy Create free account
hub / github.com/Kitware/CMake / TryCompile

Method TryCompile

Source/cmGlobalGenerator.cxx:2254–2297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2252}
2253
2254int cmGlobalGenerator::TryCompile(int jobs, std::string const& bindir,
2255 std::string const& projectName,
2256 std::string const& target, bool fast,
2257 std::string& output, cmMakefile* mf)
2258{
2259 cmBuildArgs buildArgs;
2260 buildArgs.jobs = jobs;
2261 buildArgs.binaryDir = bindir;
2262 buildArgs.projectName = projectName;
2263 buildArgs.verbose = true;
2264
2265 // if this is not set, then this is a first time configure
2266 // and there is a good chance that the try compile stuff will
2267 // take the bulk of the time, so try and guess some progress
2268 // by getting closer and closer to 100 without actually getting there.
2269 if (!this->CMakeInstance->GetState()->GetInitializedCacheValue(
2270 "CMAKE_NUMBER_OF_MAKEFILES")) {
2271 // If CMAKE_NUMBER_OF_MAKEFILES is not set
2272 // we are in the first time progress and we have no
2273 // idea how long it will be. So, just move 1/10th of the way
2274 // there each time, and don't go over 95%
2275 this->FirstTimeProgress += ((1.0f - this->FirstTimeProgress) / 30.0f);
2276 if (this->FirstTimeProgress > 0.95f) {
2277 this->FirstTimeProgress = 0.95f;
2278 }
2279 this->CMakeInstance->UpdateProgress("Configuring",
2280 this->FirstTimeProgress);
2281 }
2282
2283 std::vector<std::string> newTarget = {};
2284 if (!target.empty()) {
2285 newTarget = { target };
2286 }
2287 std::string config =
2288 mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
2289 cmBuildOptions defaultBuildOptions(false, fast, PackageResolveMode::Disable);
2290
2291 std::stringstream ostr;
2292 auto ret = this->Build(buildArgs, newTarget, ostr, "", config,
2293 defaultBuildOptions, this->TryCompileTimeout,
2294 cmSystemTools::OUTPUT_NONE, {}, BuildTryCompile::Yes);
2295 output = ostr.str();
2296 return ret;
2297}
2298
2299std::vector<cmGlobalGenerator::GeneratedMakeCommand>
2300cmGlobalGenerator::GenerateBuildCommand(

Callers

nothing calls this directly

Calls 6

BuildMethod · 0.95
strMethod · 0.80
GetStateMethod · 0.45
UpdateProgressMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected