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

Method FillCMakeSystemVariablePath

Source/cmFindBase.cxx:406–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406void cmFindBase::FillCMakeSystemVariablePath()
407{
408 cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeSystem];
409
410 bool const install_prefix_in_list =
411 !this->Makefile->IsOn("CMAKE_FIND_NO_INSTALL_PREFIX");
412 bool const remove_install_prefix = this->NoCMakeInstallPath;
413 bool const add_install_prefix = !this->NoCMakeInstallPath &&
414 this->Makefile->IsDefinitionSet("CMAKE_FIND_USE_INSTALL_PREFIX");
415
416 // We have 3 possible states for `CMAKE_SYSTEM_PREFIX_PATH` and
417 // `CMAKE_INSTALL_PREFIX`.
418 // Either we need to remove `CMAKE_INSTALL_PREFIX`, add
419 // `CMAKE_INSTALL_PREFIX`, or do nothing.
420 //
421 // When we need to remove `CMAKE_INSTALL_PREFIX` we remove the Nth occurrence
422 // of `CMAKE_INSTALL_PREFIX` from `CMAKE_SYSTEM_PREFIX_PATH`, where `N` is
423 // computed by `CMakeSystemSpecificInformation.cmake` while constructing
424 // `CMAKE_SYSTEM_PREFIX_PATH`. This ensures that if projects / toolchains
425 // have removed `CMAKE_INSTALL_PREFIX` from the list, we don't remove
426 // some other entry by mistake ( likewise for `CMAKE_STAGING_PREFIX` )
427 entry_to_remove install_entry("INSTALL", this->Makefile);
428 entry_to_remove staging_entry("STAGING", this->Makefile);
429
430 if (remove_install_prefix && install_prefix_in_list &&
431 (install_entry.valid() || staging_entry.valid())) {
432 cmValue prefix_paths =
433 this->Makefile->GetDefinition("CMAKE_SYSTEM_PREFIX_PATH");
434
435 // remove entries from CMAKE_SYSTEM_PREFIX_PATH
436 cmList expanded{ *prefix_paths };
437 install_entry.remove_self(expanded);
438 staging_entry.remove_self(expanded);
439 for (std::string& p : expanded) {
440 p = cmSystemTools::CollapseFullPath(
441 p, this->Makefile->GetCurrentSourceDirectory());
442 }
443 paths.AddPrefixPaths(expanded);
444 } else if (add_install_prefix && !install_prefix_in_list) {
445 paths.AddCMakePrefixPath("CMAKE_INSTALL_PREFIX");
446 paths.AddCMakePrefixPath("CMAKE_STAGING_PREFIX");
447 paths.AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
448 } else {
449 // Otherwise the current setup of `CMAKE_SYSTEM_PREFIX_PATH` is correct
450 paths.AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
451 }
452
453 std::string var = cmStrCat("CMAKE_SYSTEM_", this->CMakePathName, "_PATH");
454 paths.AddCMakePath(var);
455
456 if (this->CMakePathName == "PROGRAM") {
457 paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
458 } else {
459 paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
460 }
461 paths.AddSuffixes(this->SearchPathSuffixes);
462}
463

Callers 1

ExpandPathsMethod · 0.95

Calls 10

IsDefinitionSetMethod · 0.80
remove_selfMethod · 0.80
AddPrefixPathsMethod · 0.80
AddCMakePrefixPathMethod · 0.80
AddCMakePathMethod · 0.80
AddSuffixesMethod · 0.80
cmStrCatFunction · 0.70
IsOnMethod · 0.45
validMethod · 0.45
GetDefinitionMethod · 0.45

Tested by

no test coverage detected