summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx47
-rw-r--r--Tests/CustomCommand/CMakeLists.txt5
2 files changed, 48 insertions, 4 deletions
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 7c35aaf..f81945e 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -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;
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index fda4969..5446451 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -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
)