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

Method HandleInstallDestination

Source/cmFileInstaller.cxx:380–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380bool cmFileInstaller::HandleInstallDestination()
381{
382 std::string& destination = this->Destination;
383
384 // allow for / to be a valid destination
385 if (destination.size() < 2 && destination != "/") {
386 this->Status.SetError("called with inappropriate arguments. "
387 "No DESTINATION provided or .");
388 return false;
389 }
390
391 std::string sdestdir;
392 if (cmSystemTools::GetEnv("DESTDIR", sdestdir) && !sdestdir.empty()) {
393 cmSystemTools::ConvertToUnixSlashes(sdestdir);
394 char ch1 = destination[0];
395 char ch2 = destination[1];
396 char ch3 = 0;
397 if (destination.size() > 2) {
398 ch3 = destination[2];
399 }
400 int skip = 0;
401 if (ch1 != '/') {
402 int relative = 0;
403 if (((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z')) &&
404 ch2 == ':') {
405 // Assume windows
406 // let's do some destdir magic:
407 skip = 2;
408 if (ch3 != '/') {
409 relative = 1;
410 }
411 } else {
412 relative = 1;
413 }
414 if (relative) {
415 // This is relative path on unix or windows. Since we are doing
416 // destdir, this case does not make sense.
417 this->Status.SetError(
418 "called with relative DESTINATION. This "
419 "does not make sense when using DESTDIR. Specify "
420 "absolute path or remove DESTDIR environment variable.");
421 return false;
422 }
423 } else {
424 if (ch2 == '/') {
425 // looks like a network path.
426 std::string message =
427 cmStrCat("called with network path DESTINATION. This "
428 "does not make sense when using DESTDIR. Specify local "
429 "absolute path or remove DESTDIR environment variable."
430 "\nDESTINATION=\n",
431 destination);
432 this->Status.SetError(message);
433 return false;
434 }
435 }
436 destination = sdestdir + destination.substr(skip);
437 this->DestDirLength = static_cast<int>(sdestdir.size());

Callers 1

ParseMethod · 0.95

Calls 7

cmStrCatFunction · 0.70
FileExistsFunction · 0.50
sizeMethod · 0.45
SetErrorMethod · 0.45
emptyMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected