diff options
author | Brad King <brad.king@kitware.com> | 2019-01-23 13:15:53 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-23 08:16:15 -0500 |
commit | e898f48bbc944c5525f7f292b55cca8ae2fa4cae (patch) | |
tree | 1eab1f09f2da7bb15a8caef4a087957be8d06311 | |
parent | c1247d861a42fa79e7ca4cc9a793b1fa1f012dce (diff) | |
parent | 2993fc347af5db802721f1bbe0a0e05d19a28e89 (diff) | |
download | cmake-e898f48bbc944c5525f7f292b55cca8ae2fa4cae.tar.gz |
Merge topic 'getmodulesfile-string'
2993fc347a cmMakefile: GetModulesFile() accepts std::string param
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2838
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 31 | ||||
-rw-r--r-- | Source/cmIncludeCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefile.h | 4 |
6 files changed, 20 insertions, 25 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 9ae1cb9730..97ef4812e2 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -663,7 +663,7 @@ bool cmFindPackageCommand::FindModule(bool& found) module += this->Name; module += ".cmake"; bool system = false; - std::string mfile = this->Makefile->GetModulesFile(module.c_str(), system); + std::string mfile = this->Makefile->GetModulesFile(module, system); if (!mfile.empty()) { if (system) { auto it = this->DeprecatedFindModules.find(this->Name); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2d36315652..b2b0e38953 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -353,8 +353,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) } if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { - std::string setMakeProgram = - mf->GetModulesFile(this->FindMakeProgramFile.c_str()); + std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile); if (!setMakeProgram.empty()) { mf->ReadListFile(setMakeProgram); } @@ -464,11 +463,10 @@ void cmGlobalGenerator::EnableLanguage( if (this->TryCompileOuterMakefile) { // In a try-compile we can only enable languages provided by caller. - for (std::string const& li : languages) { - if (li == "NONE") { + for (std::string const& lang : languages) { + if (lang == "NONE") { this->SetLanguageEnabled("NONE", mf); } else { - const char* lang = li.c_str(); if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) { std::ostringstream e; e << "The test project needs language " << lang @@ -616,10 +614,9 @@ void cmGlobalGenerator::EnableLanguage( // load the CMakeDetermine(LANG)Compiler.cmake file to find // the compiler - for (std::string const& l : languages) { - const char* lang = l.c_str(); + for (std::string const& lang : languages) { needSetLanguageEnabledMaps[lang] = false; - if (l == "NONE") { + if (lang == "NONE") { this->SetLanguageEnabled("NONE", mf); continue; } @@ -661,8 +658,7 @@ void cmGlobalGenerator::EnableLanguage( std::string determineCompiler = "CMakeDetermine"; determineCompiler += lang; determineCompiler += "Compiler.cmake"; - std::string determineFile = - mf->GetModulesFile(determineCompiler.c_str()); + std::string determineFile = mf->GetModulesFile(determineCompiler); if (!mf->ReadListFile(determineFile)) { cmSystemTools::Error("Could not find cmake module file: ", determineCompiler.c_str()); @@ -721,9 +717,8 @@ void cmGlobalGenerator::EnableLanguage( } // loop over languages again loading CMake(LANG)Information.cmake // - for (std::string const& l : languages) { - const char* lang = l.c_str(); - if (l == "NONE") { + for (std::string const& lang : languages) { + if (lang == "NONE") { this->SetLanguageEnabled("NONE", mf); continue; } @@ -744,7 +739,7 @@ void cmGlobalGenerator::EnableLanguage( "No " << compilerName << " could be found.\n" ; /* clang-format on */ - } else if (strcmp(lang, "RC") != 0 && strcmp(lang, "ASM_MASM") != 0) { + } else if ((lang != "RC") && (lang != "ASM_MASM")) { if (!cmSystemTools::FileIsFullPath(compilerFile)) { /* clang-format off */ noCompiler << @@ -790,7 +785,7 @@ void cmGlobalGenerator::EnableLanguage( fpath = "CMake"; fpath += lang; fpath += "Information.cmake"; - std::string informationFile = mf->GetModulesFile(fpath.c_str()); + std::string informationFile = mf->GetModulesFile(fpath); if (informationFile.empty()) { cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); @@ -814,7 +809,7 @@ void cmGlobalGenerator::EnableLanguage( std::string testLang = "CMakeTest"; testLang += lang; testLang += "Compiler.cmake"; - std::string ifpath = mf->GetModulesFile(testLang.c_str()); + std::string ifpath = mf->GetModulesFile(testLang); if (!mf->ReadListFile(ifpath)) { cmSystemTools::Error("Could not find cmake module file: ", testLang.c_str()); @@ -2861,7 +2856,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) { // The rule has changed. Delete the output so it will be // built again. - fname = cmSystemTools::CollapseFullPath(fname, home.c_str()); + fname = cmSystemTools::CollapseFullPath(fname, home); cmSystemTools::RemoveFile(fname); } } else { @@ -2871,7 +2866,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, // Instead, we keep the rule hash as long as the file exists so // that if the feature is turned back on and the rule has // changed the file is still rebuilt. - std::string fpath = cmSystemTools::CollapseFullPath(fname, home.c_str()); + std::string fpath = cmSystemTools::CollapseFullPath(fname, home); if (cmSystemTools::FileExists(fpath)) { RuleHash hash; memcpy(hash.Data, line.c_str(), 32); diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index a67d09e46c..0d608bb9d0 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -67,7 +67,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args, // Not a path. Maybe module. std::string module = fname; module += ".cmake"; - std::string mfile = this->Makefile->GetModulesFile(module.c_str()); + std::string mfile = this->Makefile->GetModulesFile(module); if (!mfile.empty()) { fname = mfile; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 23afbd088c..3771737c8d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2791,7 +2791,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST"); std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in"; if (!cmSystemTools::FileIsFullPath(inFile)) { - std::string inMod = this->Makefile->GetModulesFile(inFile.c_str()); + std::string inMod = this->Makefile->GetModulesFile(inFile); if (!inMod.empty()) { inFile = inMod; } @@ -2829,7 +2829,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList( const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in"; if (!cmSystemTools::FileIsFullPath(inFile)) { - std::string inMod = this->Makefile->GetModulesFile(inFile.c_str()); + std::string inMod = this->Makefile->GetModulesFile(inFile); if (!inMod.empty()) { inFile = inMod; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9589b7f236..500776e9a8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3516,7 +3516,7 @@ void cmMakefile::DisplayStatus(const char* message, float s) const cm->UpdateProgress(message, s); } -std::string cmMakefile::GetModulesFile(const char* filename, +std::string cmMakefile::GetModulesFile(const std::string& filename, bool& system) const { std::string result; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index abe2cd1ac6..e88bb0b2dc 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -689,13 +689,13 @@ public: /** * Return a location of a file in cmake or custom modules directory */ - std::string GetModulesFile(const char* name) const + std::string GetModulesFile(const std::string& name) const { bool system; return this->GetModulesFile(name, system); } - std::string GetModulesFile(const char* name, bool& system) const; + std::string GetModulesFile(const std::string& name, bool& system) const; ///! Set/Get a property of this directory void SetProperty(const std::string& prop, const char* value); |