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

Method CreateCDCommand

Source/cmLocalUnixMakefileGenerator3.cxx:2282–2319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2280}
2281
2282void cmLocalUnixMakefileGenerator3::CreateCDCommand(
2283 std::vector<std::string>& commands, std::string const& tgtDir,
2284 std::string const& relDir)
2285{
2286 // do we need to cd?
2287 if (tgtDir == relDir) {
2288 return;
2289 }
2290
2291 // In a Windows shell we must change drive letter too. The shell
2292 // used by NMake and Borland make does not support "cd /d" so this
2293 // feature simply cannot work with them (Borland make does not even
2294 // support changing the drive letter with just "d:").
2295 char const* cd_cmd = this->IsMinGWMake() ? "cd /d " : "cd ";
2296
2297 cmGlobalUnixMakefileGenerator3* gg =
2298 static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
2299 if (!gg->UnixCD) {
2300 // On Windows we must perform each step separately and then change
2301 // back because the shell keeps the working directory between
2302 // commands.
2303 std::string cmd =
2304 cmStrCat(cd_cmd, this->ConvertToOutputForExisting(tgtDir));
2305 commands.insert(commands.begin(), cmd);
2306
2307 // Change back to the starting directory.
2308 cmd = cmStrCat(cd_cmd, this->ConvertToOutputForExisting(relDir));
2309 commands.push_back(std::move(cmd));
2310 } else {
2311 // On UNIX we must construct a single shell command to change
2312 // directory and build because make resets the directory between
2313 // each command.
2314 std::string outputForExisting = this->ConvertToOutputForExisting(tgtDir);
2315 std::string prefix = cd_cmd + outputForExisting + " && ";
2316 std::transform(commands.begin(), commands.end(), commands.begin(),
2317 [&prefix](std::string const& s) { return prefix + s; });
2318 }
2319}

Calls 9

moveFunction · 0.85
transformFunction · 0.85
IsMinGWMakeMethod · 0.80
push_backMethod · 0.80
cmStrCatFunction · 0.70
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected