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

Method ComputeOutputDir

Source/cmGeneratorTarget.cxx:4571–4642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4569}
4570
4571bool cmGeneratorTarget::ComputeOutputDir(std::string const& config,
4572 cmStateEnums::ArtifactType artifact,
4573 std::string& out) const
4574{
4575 bool usesDefaultOutputDir = false;
4576 std::string conf = config;
4577
4578 // Look for a target property defining the target output directory
4579 // based on the target type.
4580 std::string targetTypeName = this->GetOutputTargetType(artifact);
4581 std::string propertyName;
4582 if (!targetTypeName.empty()) {
4583 propertyName = cmStrCat(targetTypeName, "_OUTPUT_DIRECTORY");
4584 }
4585
4586 // Check for a per-configuration output directory target property.
4587 std::string configUpper = cmSystemTools::UpperCase(conf);
4588 std::string configProp;
4589 if (!targetTypeName.empty()) {
4590 configProp = cmStrCat(targetTypeName, "_OUTPUT_DIRECTORY_", configUpper);
4591 }
4592
4593 // Select an output directory.
4594 if (cmValue config_outdir = this->GetProperty(configProp)) {
4595 // Use the user-specified per-configuration output directory.
4596 out = cmGeneratorExpression::Evaluate(*config_outdir, this->LocalGenerator,
4597 config, this);
4598
4599 // Skip per-configuration subdirectory.
4600 conf.clear();
4601 } else if (cmValue outdir = this->GetProperty(propertyName)) {
4602 // Use the user-specified output directory.
4603 out = cmGeneratorExpression::Evaluate(*outdir, this->LocalGenerator,
4604 config, this);
4605 // Skip per-configuration subdirectory if the value contained a
4606 // generator expression.
4607 if (out != *outdir) {
4608 conf.clear();
4609 }
4610 } else if (this->GetType() == cmStateEnums::EXECUTABLE) {
4611 // Lookup the output path for executables.
4612 out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
4613 } else if (this->GetType() == cmStateEnums::STATIC_LIBRARY ||
4614 this->GetType() == cmStateEnums::SHARED_LIBRARY ||
4615 this->GetType() == cmStateEnums::MODULE_LIBRARY) {
4616 // Lookup the output path for libraries.
4617 out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
4618 }
4619 if (out.empty()) {
4620 // Default to the current output directory.
4621 usesDefaultOutputDir = true;
4622 out = ".";
4623 }
4624
4625 // Convert the output path to a full path in case it is
4626 // specified as a relative path. Treat a relative path as
4627 // relative to the current output directory for this makefile.
4628 out = (cmSystemTools::CollapseFullPath(

Callers 2

UsesDefaultOutputDirMethod · 0.95
GetOutputInfoMethod · 0.95

Calls 9

GetOutputTargetTypeMethod · 0.95
GetPropertyMethod · 0.95
GetTypeMethod · 0.95
cmStrCatFunction · 0.70
emptyMethod · 0.45
clearMethod · 0.45
GetGlobalGeneratorMethod · 0.45

Tested by

no test coverage detected