ENH: Add LOCATION to GET_TARGET_PROPERTY. Closes Bug #34 - Add to GET_TARGET_PROPERTY location of target
This commit is contained in:
parent
5a5cd54730
commit
b2bddc9f0d
|
@ -32,12 +32,53 @@ bool cmGetTargetPropertyCommand::InitialPass(
|
|||
if ( i != targets.end())
|
||||
{
|
||||
cmTarget& target = i->second;
|
||||
const char *prop = target.GetProperty(args[2].c_str());
|
||||
if (prop)
|
||||
if ( args[2] == "LOCATION" )
|
||||
{
|
||||
m_Makefile->AddDefinition(var, prop);
|
||||
std::string target_location;
|
||||
switch( target.GetType() )
|
||||
{
|
||||
case cmTarget::STATIC_LIBRARY:
|
||||
case cmTarget::MODULE_LIBRARY:
|
||||
case cmTarget::SHARED_LIBRARY:
|
||||
target_location = m_Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
|
||||
break;
|
||||
case cmTarget::EXECUTABLE:
|
||||
target_location = m_Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
|
||||
break;
|
||||
default:
|
||||
m_Makefile->AddDefinition(var, "NOTFOUND");
|
||||
return true;
|
||||
}
|
||||
if ( target_location.size() == 0 )
|
||||
{
|
||||
target_location += m_Makefile->GetCurrentOutputDirectory();
|
||||
}
|
||||
if ( target_location.size() > 0 )
|
||||
{
|
||||
target_location += "/";
|
||||
}
|
||||
const char* cfgid = m_Makefile->GetDefinition("CMAKE_CFG_INTDIR");
|
||||
if ( cfgid && strcmp(cfgid, ".") != 0 )
|
||||
{
|
||||
target_location += cfgid;
|
||||
target_location += "/";
|
||||
}
|
||||
|
||||
cmLocalGenerator* lg = m_Makefile->GetLocalGenerator();
|
||||
target_location += lg->GetFullTargetName(targetName, target);
|
||||
m_Makefile->AddDefinition(var, target_location.c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *prop = 0;
|
||||
prop = target.GetProperty(args[2].c_str());
|
||||
if (prop)
|
||||
{
|
||||
m_Makefile->AddDefinition(var, prop);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Makefile->AddDefinition(var, "NOTFOUND");
|
||||
return true;
|
||||
|
|
|
@ -22,12 +22,15 @@ SET (EXECUTABLE_OUTPUT_PATH
|
|||
# add the executable that will generate the file
|
||||
ADD_EXECUTABLE(generator generator.cxx)
|
||||
|
||||
GET_TARGET_PROPERTY(generator_PATH generator LOCATION)
|
||||
MESSAGE("Location ${generator_PATH}")
|
||||
|
||||
# the folowing assumes that a cmSourceFile
|
||||
# is instantiated for the output, with GENERATED 1
|
||||
# at the end of the day this becomes a what in VS ?
|
||||
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/generated.c
|
||||
DEPENDS generator
|
||||
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/generator
|
||||
COMMAND ${generator_PATH}
|
||||
ARGS ${PROJECT_BINARY_DIR}/generated.c
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue