diff options
author | Brad King <brad.king@kitware.com> | 2021-05-12 19:51:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-13 16:47:25 (GMT) |
commit | 15fa3200715869d5acb94a282feb301d2e10a0eb (patch) | |
tree | 9c5d6c18b03b2917cc54d7fa2cfa5b9c89d8e4b0 /Source/cmDependsFortran.cxx | |
parent | 1879f1bcbc4e2fbd9eaca4eff351ab928c4a3268 (diff) | |
download | CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.zip CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.tar.gz CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.tar.bz2 |
cmLocalGenerator: Factor out relative path conversion helpers
Most calls to `MaybeConvertToRelativePath` use one of our common work
directories (e.g. top of the build tree) as the local path. Add helpers
for each of the common cases to simplify and clarify call sites.
Diffstat (limited to 'Source/cmDependsFortran.cxx')
-rw-r--r-- | Source/cmDependsFortran.cxx | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 636b5e4..bca26b9 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -190,8 +190,6 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, cmGeneratedFileStream fcStream(fcName); fcStream << "# Remove fortran modules provided by this target.\n"; fcStream << "FILE(REMOVE"; - std::string currentBinDir = - this->LocalGenerator->GetCurrentBinaryDirectory(); for (std::string const& i : provides) { std::string mod_upper = cmStrCat(mod_dir, '/'); std::string mod_lower = cmStrCat(mod_dir, '/'); @@ -199,13 +197,13 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, std::string stamp = cmStrCat(stamp_dir, '/', i, ".stamp"); fcStream << "\n" " \"" - << this->MaybeConvertToRelativePath(currentBinDir, mod_lower) + << this->LocalGenerator->MaybeRelativeToCurBinDir(mod_lower) << "\"\n" " \"" - << this->MaybeConvertToRelativePath(currentBinDir, mod_upper) + << this->LocalGenerator->MaybeRelativeToCurBinDir(mod_upper) << "\"\n" " \"" - << this->MaybeConvertToRelativePath(currentBinDir, stamp) + << this->LocalGenerator->MaybeRelativeToCurBinDir(stamp) << "\"\n"; } fcStream << " )\n"; @@ -315,8 +313,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, std::string const& src = info.Source; // Write the include dependencies to the output stream. - std::string binDir = this->LocalGenerator->GetBinaryDirectory(); - std::string obj_i = this->MaybeConvertToRelativePath(binDir, obj); + std::string obj_i = this->LocalGenerator->MaybeRelativeToTopBinDir(obj); std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i); internalDepends << obj_i << "\n " << src << '\n'; if (!info.Includes.empty()) { @@ -331,7 +328,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, } for (std::string const& i : info.Includes) { std::string dependee = cmSystemTools::ConvertToOutputPath( - this->MaybeConvertToRelativePath(binDir, i)); + this->LocalGenerator->MaybeRelativeToTopBinDir(i)); if (supportLongLineDepend) { makeDepends << ' ' << lineContinue << ' ' << dependee; } else { @@ -358,7 +355,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, if (!required->second.empty()) { // This module is known. Depend on its timestamp file. std::string stampFile = cmSystemTools::ConvertToOutputPath( - this->MaybeConvertToRelativePath(binDir, required->second)); + this->LocalGenerator->MaybeRelativeToTopBinDir(required->second)); makeDepends << obj_m << ": " << stampFile << '\n'; } else { // This module is not known to CMake. Try to locate it where @@ -366,7 +363,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, std::string module; if (this->FindModule(i, module)) { module = cmSystemTools::ConvertToOutputPath( - this->MaybeConvertToRelativePath(binDir, module)); + this->LocalGenerator->MaybeRelativeToTopBinDir(module)); makeDepends << obj_m << ": " << module << '\n'; } } @@ -385,10 +382,10 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, // try various cases for the real mod file name. std::string modFile = cmStrCat(mod_dir, '/', i); modFile = this->LocalGenerator->ConvertToOutputFormat( - this->MaybeConvertToRelativePath(binDir, modFile), + this->LocalGenerator->MaybeRelativeToTopBinDir(modFile), cmOutputConverter::SHELL); std::string stampFile = cmStrCat(stamp_dir, '/', i, ".stamp"); - stampFile = this->MaybeConvertToRelativePath(binDir, stampFile); + stampFile = this->LocalGenerator->MaybeRelativeToTopBinDir(stampFile); std::string const stampFileForShell = this->LocalGenerator->ConvertToOutputFormat(stampFile, cmOutputConverter::SHELL); @@ -423,7 +420,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, // the target finishes building. std::string driver = cmStrCat(this->TargetDirectory, "/build"); driver = cmSystemTools::ConvertToOutputPath( - this->MaybeConvertToRelativePath(binDir, driver)); + this->LocalGenerator->MaybeRelativeToTopBinDir(driver)); makeDepends << driver << ": " << obj_m << ".provides.build\n"; } @@ -679,9 +676,3 @@ bool cmDependsFortran::ModulesDiffer(const std::string& modFile, // content. return cmFortranStreamsDiffer(finModFile, finStampFile); } - -std::string cmDependsFortran::MaybeConvertToRelativePath( - std::string const& base, std::string const& path) -{ - return this->LocalGenerator->MaybeConvertToRelativePath(base, path); -} |