| 4569 | } |
| 4570 | |
| 4571 | bool 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( |
no test coverage detected