ENH: Finished CMAKE_<CONFIG>_POSTFIX feature and documented it. The value of this variable is used when a library target is created to initialize the <CONFIG>_POSTFIX target property. The value of this property is used (even for executables) to define a per-configuration postfix on the name of the target. Also enabled use of the OUTPUT_NAME property for non-executable targets.

This commit is contained in:
Brad King 2006-03-01 22:45:13 -05:00
parent ae62f66033
commit 54732b0607
2 changed files with 48 additions and 11 deletions

View File

@ -69,7 +69,15 @@ public:
"(for SHARED library targets). " "(for SHARED library targets). "
"OUTPUT_NAME sets the real name of a target when it is built and " "OUTPUT_NAME sets the real name of a target when it is built and "
"can be used to help create two targets of the same name even though " "can be used to help create two targets of the same name even though "
"CMake requires unique logical target names.\n" "CMake requires unique logical target names. "
"<CONFIG>_POSTFIX sets a postfix for the real name of the target "
"when it is built under the configuration named by <CONFIG> "
"(in upper-case, such as \"DEBUG_POSTFIX\"). The value of "
"this property is initialized when the target is created to the "
"value of the variable CMAKE_<CONFIG>_POSTFIX (except for executable "
"targets because earlier CMake versions which did not use this "
"variable for executables)."
"\n"
"The LINK_FLAGS property can be used to add extra flags to the " "The LINK_FLAGS property can be used to add extra flags to the "
"link step of a target. " "link step of a target. "
"DEFINE_SYMBOL sets the name of the preprocessor symbol defined when " "DEFINE_SYMBOL sets the name of the preprocessor symbol defined when "

View File

@ -56,6 +56,39 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("INSTALL_RPATH", ""); this->SetPropertyDefault("INSTALL_RPATH", "");
this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF");
this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF");
// Collect the set of configuration types.
std::vector<std::string> configNames;
if(const char* configurationTypes =
mf->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
{
cmSystemTools::ExpandListArgument(configurationTypes, configNames);
}
else if(const char* buildType = mf->GetDefinition("CMAKE_BUILD_TYPE"))
{
if(*buildType)
{
configNames.push_back(buildType);
}
}
// Setup per-configuration property default values.
for(std::vector<std::string>::iterator ci = configNames.begin();
ci != configNames.end(); ++ci)
{
// Initialize per-configuration name postfix property from the
// variable only for non-executable targets. This preserves
// compatibility with previous CMake versions in which executables
// did not support this variable. Projects may still specify the
// property directly. TODO: Make this depend on backwards
// compatibility setting.
if(m_TargetType != cmTarget::EXECUTABLE)
{
std::string property = cmSystemTools::UpperCase(*ci);
property += "_POSTFIX";
this->SetPropertyDefault(property.c_str(), 0);
}
}
} }
void cmTarget::TraceVSDependencies(std::string projFile, void cmTarget::TraceVSDependencies(std::string projFile,
@ -1130,13 +1163,11 @@ void cmTarget::GetFullNameInternal(TargetType type,
? this->GetProperty("IMPORT_SUFFIX") ? this->GetProperty("IMPORT_SUFFIX")
: this->GetProperty("SUFFIX")); : this->GetProperty("SUFFIX"));
const char* configPostfix = 0; const char* configPostfix = 0;
if(config && *config && type != cmTarget::EXECUTABLE) if(config && *config)
{ {
std::string configVar = "CMAKE_"; std::string configProp = cmSystemTools::UpperCase(config);
configVar += config; configProp += "_POSTFIX";
configVar += "_POSTFIX"; configPostfix = this->GetProperty(configProp.c_str());
configVar = cmSystemTools::UpperCase(configVar);
configPostfix = m_Makefile->GetDefinition(configVar.c_str());
} }
const char* prefixVar = this->GetPrefixVariableInternal(type, implib); const char* prefixVar = this->GetPrefixVariableInternal(type, implib);
const char* suffixVar = this->GetSuffixVariableInternal(type, implib); const char* suffixVar = this->GetSuffixVariableInternal(type, implib);
@ -1172,10 +1203,8 @@ void cmTarget::GetFullNameInternal(TargetType type,
// Begin the final name with the prefix. // Begin the final name with the prefix.
outPrefix = targetPrefix?targetPrefix:""; outPrefix = targetPrefix?targetPrefix:"";
// Append the target name or property-specified name. Support this // Append the target name or property-specified name.
// only for executable targets. if(const char* outname = this->GetProperty("OUTPUT_NAME"))
const char* outname = this->GetProperty("OUTPUT_NAME");
if(outname && type == cmTarget::EXECUTABLE)
{ {
outBase = outname; outBase = outname;
} }