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

Method GetModulesFile

Source/cmMakefile.cxx:3401–3463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3399}
3400
3401std::string cmMakefile::GetModulesFile(cm::string_view filename, bool& system,
3402 bool debug,
3403 std::string& debugBuffer) const
3404{
3405 std::string result;
3406
3407 std::string moduleInCMakeRoot;
3408 std::string moduleInCMakeModulePath;
3409
3410 // Always search in CMAKE_MODULE_PATH:
3411 cmValue cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH");
3412 if (cmakeModulePath) {
3413 cmList modulePath{ *cmakeModulePath };
3414
3415 // Look through the possible module directories.
3416 for (std::string itempl : modulePath) {
3417 cmSystemTools::ConvertToUnixSlashes(itempl);
3418 itempl += "/";
3419 itempl += filename;
3420 if (cmSystemTools::FileExists(itempl)) {
3421 moduleInCMakeModulePath = itempl;
3422 break;
3423 }
3424 if (debug) {
3425 debugBuffer = cmStrCat(debugBuffer, " ", itempl, '\n');
3426 }
3427 }
3428 }
3429
3430 // Always search in the standard modules location.
3431 moduleInCMakeRoot =
3432 cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/", filename);
3433 cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
3434 if (!cmSystemTools::FileExists(moduleInCMakeRoot)) {
3435 if (debug) {
3436 debugBuffer = cmStrCat(debugBuffer, " ", moduleInCMakeRoot, '\n');
3437 }
3438 moduleInCMakeRoot.clear();
3439 }
3440
3441 // Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file
3442 // from which we are being called is located itself in CMAKE_ROOT, then
3443 // prefer results from CMAKE_ROOT depending on the policy setting.
3444 if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty()) {
3445 cmValue currentFile = this->GetDefinition(kCMAKE_CURRENT_LIST_FILE);
3446 std::string mods = cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/");
3447 if (currentFile && cmSystemTools::IsSubDirectory(*currentFile, mods)) {
3448 system = true;
3449 result = moduleInCMakeRoot;
3450 } else {
3451 system = false;
3452 result = moduleInCMakeModulePath;
3453 }
3454 } else if (!moduleInCMakeModulePath.empty()) {
3455 system = false;
3456 result = moduleInCMakeModulePath;
3457 } else {
3458 system = true;

Callers 12

FindMakeProgramMethod · 0.45
EnableLanguageMethod · 0.45
FindModuleMethod · 0.45
IncludeByVariableFunction · 0.45
cmIncludeCommandFunction · 0.45
FindPackageMethod · 0.45
ReadInScriptMethod · 0.45
ReadListFileMethod · 0.45
FindTemplateMethod · 0.45
mainFunction · 0.45

Calls 5

GetDefinitionMethod · 0.95
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
clearMethod · 0.45
emptyMethod · 0.45

Tested by 1

ReadInScriptMethod · 0.36