ENH: Allow more specification of target file names
This creates target properties ARCHIVE_OUTPUT_NAME, LIBRARY_OUTPUT_NAME, and RUNTIME_OUTPUT_NAME, and per-configuration equivalent properties ARCHIVE_OUTPUT_NAME_<CONFIG>, LIBRARY_OUTPUT_NAME_<CONFIG>, and RUNTIME_OUTPUT_NAME_<CONFIG>. They allow specification of target output file names on a per-type, per-configuration basis. For example, a .dll and its .lib import library may have different base names. For consistency and to avoid ambiguity, the old <CONFIG>_OUTPUT_NAME property is now also available as OUTPUT_NAME_<CONFIG>. See issue #8920.
This commit is contained in:
parent
617eb981d4
commit
2740db5ede
@ -468,12 +468,21 @@ void cmTarget::DefineProperties(cmake *cm)
|
|||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("OUTPUT_NAME", cmProperty::TARGET,
|
("OUTPUT_NAME", cmProperty::TARGET,
|
||||||
"Sets the real name of a target when it is built.",
|
"Output name for target files.",
|
||||||
"Sets the real name of a target when it is built and "
|
"This sets the base name for output files created for an executable or "
|
||||||
"can be used to help create two targets of the same name even though "
|
"library target. "
|
||||||
"CMake requires unique logical target names. There is also a "
|
"If not set, the logical target name is used by default.");
|
||||||
"<CONFIG>_OUTPUT_NAME that can set the output name on a "
|
|
||||||
"per-configuration basis.");
|
cm->DefineProperty
|
||||||
|
("OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
|
||||||
|
"Per-configuration target file base name.",
|
||||||
|
"This is the configuration-specific version of OUTPUT_NAME.");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("<CONFIG>_OUTPUT_NAME", cmProperty::TARGET,
|
||||||
|
"Old per-configuration target file base name.",
|
||||||
|
"This is a configuration-specific version of OUTPUT_NAME. "
|
||||||
|
"Use OUTPUT_NAME_<CONFIG> instead.");
|
||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("PRE_INSTALL_SCRIPT", cmProperty::TARGET,
|
("PRE_INSTALL_SCRIPT", cmProperty::TARGET,
|
||||||
@ -791,9 +800,36 @@ void cmTarget::DefineProperties(cmake *cm)
|
|||||||
"This property is initialized by the value of the variable "
|
"This property is initialized by the value of the variable "
|
||||||
"CMAKE_RUNTIME_OUTPUT_DIRECTORY if it is set when a target is created.");
|
"CMAKE_RUNTIME_OUTPUT_DIRECTORY if it is set when a target is created.");
|
||||||
|
|
||||||
// define some properties without documentation
|
cm->DefineProperty
|
||||||
cm->DefineProperty("DEBUG_OUTPUT_NAME", cmProperty::TARGET,0,0);
|
("ARCHIVE_OUTPUT_NAME", cmProperty::TARGET,
|
||||||
cm->DefineProperty("RELEASE_OUTPUT_NAME", cmProperty::TARGET,0,0);
|
"Output name for ARCHIVE target files.",
|
||||||
|
"This property specifies the base name for archive target files. "
|
||||||
|
"It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. "
|
||||||
|
CM_TARGET_FILE_TYPES_DOC);
|
||||||
|
cm->DefineProperty
|
||||||
|
("ARCHIVE_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
|
||||||
|
"Per-configuration output name for ARCHIVE target files.",
|
||||||
|
"This is the configuration-specific version of ARCHIVE_OUTPUT_NAME.");
|
||||||
|
cm->DefineProperty
|
||||||
|
("LIBRARY_OUTPUT_NAME", cmProperty::TARGET,
|
||||||
|
"Output name for LIBRARY target files.",
|
||||||
|
"This property specifies the base name for library target files. "
|
||||||
|
"It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. "
|
||||||
|
CM_TARGET_FILE_TYPES_DOC);
|
||||||
|
cm->DefineProperty
|
||||||
|
("LIBRARY_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
|
||||||
|
"Per-configuration output name for LIBRARY target files.",
|
||||||
|
"This is the configuration-specific version of LIBRARY_OUTPUT_NAME.");
|
||||||
|
cm->DefineProperty
|
||||||
|
("RUNTIME_OUTPUT_NAME", cmProperty::TARGET,
|
||||||
|
"Output name for RUNTIME target files.",
|
||||||
|
"This property specifies the base name for runtime target files. "
|
||||||
|
"It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. "
|
||||||
|
CM_TARGET_FILE_TYPES_DOC);
|
||||||
|
cm->DefineProperty
|
||||||
|
("RUNTIME_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
|
||||||
|
"Per-configuration output name for RUNTIME target files.",
|
||||||
|
"This is the configuration-specific version of RUNTIME_OUTPUT_NAME.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmTarget::SetType(TargetType type, const char* name)
|
void cmTarget::SetType(TargetType type, const char* name)
|
||||||
@ -2654,25 +2690,7 @@ void cmTarget::GetFullNameInternal(TargetType type,
|
|||||||
outPrefix = targetPrefix?targetPrefix:"";
|
outPrefix = targetPrefix?targetPrefix:"";
|
||||||
|
|
||||||
// Append the target name or property-specified name.
|
// Append the target name or property-specified name.
|
||||||
const char* outName = 0;
|
outBase += this->GetOutputName(config, implib);
|
||||||
if(config && *config)
|
|
||||||
{
|
|
||||||
std::string configProp = cmSystemTools::UpperCase(config);
|
|
||||||
configProp += "_OUTPUT_NAME";
|
|
||||||
outName = this->GetProperty(configProp.c_str());
|
|
||||||
}
|
|
||||||
if(!outName)
|
|
||||||
{
|
|
||||||
outName = this->GetProperty("OUTPUT_NAME");
|
|
||||||
}
|
|
||||||
if(outName)
|
|
||||||
{
|
|
||||||
outBase = outName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
outBase = this->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append the per-configuration postfix.
|
// Append the per-configuration postfix.
|
||||||
outBase += configPostfix?configPostfix:"";
|
outBase += configPostfix?configPostfix:"";
|
||||||
@ -3315,6 +3333,43 @@ std::string const& cmTarget::ComputeBaseOutputDir(bool implib)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
std::string cmTarget::GetOutputName(const char* config, bool implib)
|
||||||
|
{
|
||||||
|
std::vector<std::string> props;
|
||||||
|
std::string type = this->GetOutputTargetType(implib);
|
||||||
|
std::string configUpper = cmSystemTools::UpperCase(config? config : "");
|
||||||
|
if(!type.empty() && !configUpper.empty())
|
||||||
|
{
|
||||||
|
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
|
||||||
|
props.push_back(type + "_OUTPUT_NAME_" + configUpper);
|
||||||
|
}
|
||||||
|
if(!type.empty())
|
||||||
|
{
|
||||||
|
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME
|
||||||
|
props.push_back(type + "_OUTPUT_NAME");
|
||||||
|
}
|
||||||
|
if(!configUpper.empty())
|
||||||
|
{
|
||||||
|
// OUTPUT_NAME_<CONFIG>
|
||||||
|
props.push_back("OUTPUT_NAME_" + configUpper);
|
||||||
|
// <CONFIG>_OUTPUT_NAME
|
||||||
|
props.push_back(configUpper + "_OUTPUT_NAME");
|
||||||
|
}
|
||||||
|
// OUTPUT_NAME
|
||||||
|
props.push_back("OUTPUT_NAME");
|
||||||
|
|
||||||
|
for(std::vector<std::string>::const_iterator i = props.begin();
|
||||||
|
i != props.end(); ++i)
|
||||||
|
{
|
||||||
|
if(const char* outName = this->GetProperty(i->c_str()))
|
||||||
|
{
|
||||||
|
return outName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmTarget::GetFrameworkVersion()
|
std::string cmTarget::GetFrameworkVersion()
|
||||||
{
|
{
|
||||||
|
@ -501,6 +501,9 @@ private:
|
|||||||
std::string GetOutputDir(bool implib);
|
std::string GetOutputDir(bool implib);
|
||||||
std::string const& ComputeBaseOutputDir(bool implib);
|
std::string const& ComputeBaseOutputDir(bool implib);
|
||||||
|
|
||||||
|
// Get the target base name.
|
||||||
|
std::string GetOutputName(const char* config, bool implib);
|
||||||
|
|
||||||
const char* ImportedGetLocation(const char* config);
|
const char* ImportedGetLocation(const char* config);
|
||||||
const char* NormalGetLocation(const char* config);
|
const char* NormalGetLocation(const char* config);
|
||||||
|
|
||||||
|
@ -36,6 +36,15 @@ set_property(TARGET testLib3 PROPERTY LINK_INTERFACE_LIBRARIES "")
|
|||||||
set_property(TARGET testLib3 PROPERTY VERSION 1.2)
|
set_property(TARGET testLib3 PROPERTY VERSION 1.2)
|
||||||
set_property(TARGET testLib3 PROPERTY SOVERSION 3)
|
set_property(TARGET testLib3 PROPERTY SOVERSION 3)
|
||||||
|
|
||||||
|
# Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME[_<CONFIG>] properties.
|
||||||
|
set_property(TARGET testLib3 PROPERTY RUNTIME_OUTPUT_NAME_DEBUG testLib3dll-d)
|
||||||
|
set_property(TARGET testLib3 PROPERTY RUNTIME_OUTPUT_NAME_RELEASE testLib3dll-r)
|
||||||
|
set_property(TARGET testLib3 PROPERTY RUNTIME_OUTPUT_NAME testLib3dll)
|
||||||
|
set_property(TARGET testLib3 PROPERTY LIBRARY_OUTPUT_NAME_DEBUG testLib3lib-d)
|
||||||
|
set_property(TARGET testLib3 PROPERTY LIBRARY_OUTPUT_NAME_RELEASE testLib3lib-r)
|
||||||
|
set_property(TARGET testLib3 PROPERTY LIBRARY_OUTPUT_NAME testLib3lib)
|
||||||
|
set_property(TARGET testLib3 PROPERTY ARCHIVE_OUTPUT_NAME testLib3import)
|
||||||
|
|
||||||
add_library(testLib4 SHARED testLib4.c)
|
add_library(testLib4 SHARED testLib4.c)
|
||||||
set_property(TARGET testLib4 PROPERTY FRAMEWORK 1)
|
set_property(TARGET testLib4 PROPERTY FRAMEWORK 1)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ IF(STAGE2)
|
|||||||
)
|
)
|
||||||
SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel)
|
SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel)
|
||||||
SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
|
SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
|
||||||
SET(t4NAMES test4 test4${CMAKE_DEBUG_POSTFIX})
|
SET(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX})
|
||||||
|
|
||||||
# Make sure the install script ran.
|
# Make sure the install script ran.
|
||||||
SET(CMAKE_INSTALL_SCRIPT_DID_RUN 0)
|
SET(CMAKE_INSTALL_SCRIPT_DID_RUN 0)
|
||||||
@ -165,6 +165,10 @@ ELSE(STAGE2)
|
|||||||
ADD_LIBRARY(test3 MODULE lib3.cxx)
|
ADD_LIBRARY(test3 MODULE lib3.cxx)
|
||||||
ADD_LIBRARY(test4 SHARED lib4.cxx)
|
ADD_LIBRARY(test4 SHARED lib4.cxx)
|
||||||
|
|
||||||
|
# Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties.
|
||||||
|
SET_PROPERTY(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out)
|
||||||
|
SET_PROPERTY(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out)
|
||||||
|
|
||||||
ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h)
|
ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h)
|
||||||
TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4)
|
TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4)
|
||||||
SET(install_target SimpleInstall)
|
SET(install_target SimpleInstall)
|
||||||
|
@ -33,7 +33,7 @@ IF(STAGE2)
|
|||||||
)
|
)
|
||||||
SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel)
|
SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel)
|
||||||
SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
|
SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
|
||||||
SET(t4NAMES test4 test4${CMAKE_DEBUG_POSTFIX})
|
SET(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX})
|
||||||
|
|
||||||
# Make sure the install script ran.
|
# Make sure the install script ran.
|
||||||
SET(CMAKE_INSTALL_SCRIPT_DID_RUN 0)
|
SET(CMAKE_INSTALL_SCRIPT_DID_RUN 0)
|
||||||
@ -165,6 +165,10 @@ ELSE(STAGE2)
|
|||||||
ADD_LIBRARY(test3 MODULE lib3.cxx)
|
ADD_LIBRARY(test3 MODULE lib3.cxx)
|
||||||
ADD_LIBRARY(test4 SHARED lib4.cxx)
|
ADD_LIBRARY(test4 SHARED lib4.cxx)
|
||||||
|
|
||||||
|
# Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties.
|
||||||
|
SET_PROPERTY(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out)
|
||||||
|
SET_PROPERTY(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out)
|
||||||
|
|
||||||
ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h)
|
ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h)
|
||||||
TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4)
|
TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4)
|
||||||
SET(install_target SimpleInstall)
|
SET(install_target SimpleInstall)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user