summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-06-20 18:00:48 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-06-20 18:00:48 (GMT)
commit26c53fe14c4d6cabb8b7476f5c19ca7088199841 (patch)
tree0a21177b04547b365a0c82a52979315cb4adcd97 /Source
parent490119d2aa31eaaeb99a145ab3e7b2aee2c957db (diff)
downloadCMake-26c53fe14c4d6cabb8b7476f5c19ca7088199841.zip
CMake-26c53fe14c4d6cabb8b7476f5c19ca7088199841.tar.gz
CMake-26c53fe14c4d6cabb8b7476f5c19ca7088199841.tar.bz2
ENH: modified GET_TARGET_PROPERTIES to work with all targets
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx54
-rw-r--r--Source/cmGetTargetPropertyCommand.h4
-rw-r--r--Source/cmGlobalGenerator.h5
-rw-r--r--Source/cmMakefile.cxx45
4 files changed, 57 insertions, 51 deletions
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 9c8ed4f..45164da 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -27,56 +27,18 @@ bool cmGetTargetPropertyCommand::InitialPass(
}
const char* var = args[0].c_str();
const char* targetName = args[1].c_str();
- cmTargets& targets = m_Makefile->GetTargets();
- cmTargets::iterator i = targets.find(targetName);
- if ( i != targets.end())
+
+ cmTarget *tgt = m_Makefile->GetLocalGenerator()->GetGlobalGenerator()
+ ->FindTarget(0,targetName);
+ if (tgt)
{
- cmTarget& target = i->second;
- if ( args[2] == "LOCATION" )
+ cmTarget& target = *tgt;
+ const char *prop = target.GetProperty(args[2].c_str());
+ if (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 += "/";
- }
-
- target_location += target.GetFullName(m_Makefile);
- m_Makefile->AddDefinition(var, target_location.c_str());
+ m_Makefile->AddDefinition(var, prop);
return true;
}
- else
- {
- const char *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/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h
index 3f617a0..8e455c3 100644
--- a/Source/cmGetTargetPropertyCommand.h
+++ b/Source/cmGetTargetPropertyCommand.h
@@ -60,7 +60,9 @@ public:
"a target is built. The read-only property \"LOCATION\" specifies "
"the full path to the file on disk that will be created for the "
"target. This is very useful for executable targets to get "
- "the path to the executable file for use in a custom command.";
+ "the path to the executable file for use in a custom command. "
+ "This command can get properties for any target so far created. "
+ "The targets do not need to be in the current CMakeLists.txt file.";
}
cmTypeMacro(cmGetTargetPropertyCommand, cmCommand);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 8b35116..6ed8609 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -143,6 +143,9 @@ public:
*/
void FindMakeProgram(cmMakefile*);
+ ///! Find a target by name by searching the local generators.
+ cmTarget* FindTarget(const char* project, const char* name);
+
protected:
// Fill the m_ProjectMap, this must be called after m_LocalGenerators has been populated.
void FillProjectMap();
@@ -159,8 +162,6 @@ protected:
// map from project name to vector of local generators in that project
std::map<cmStdString, std::vector<cmLocalGenerator*> > m_ProjectMap;
- ///! Find a target by name by searching the local generators.
- cmTarget* FindTarget(const char* project, const char* name);
private:
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2248ec4..abb29ea 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1079,7 +1079,8 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
target.SetInAll(true);
target.GetSourceLists() = srcs;
this->AddGlobalLinkInformation(lname, target);
- m_Targets.insert(cmTargets::value_type(lname,target));
+ cmTargets::iterator it =
+ m_Targets.insert(cmTargets::value_type(lname,target)).first;
// Add an entry into the cache
std::string libPath = lname;
@@ -1088,7 +1089,27 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
AddCacheEntry(libPath.c_str(),
this->GetCurrentOutputDirectory(),
"Path to a library", cmCacheManager::INTERNAL);
-
+
+ // set the LOCATION property of the target
+ std::string target_location;
+ target_location = this->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
+ if ( target_location.size() == 0 )
+ {
+ target_location += this->GetCurrentOutputDirectory();
+ }
+ if ( target_location.size() > 0 )
+ {
+ target_location += "/";
+ }
+ const char* cfgid = this->GetDefinition("CMAKE_CFG_INTDIR");
+ if ( cfgid && strcmp(cfgid, ".") != 0 )
+ {
+ target_location += cfgid;
+ target_location += "/";
+ }
+ target_location += target.GetFullName(this);
+ target.SetProperty("LOCATION",target_location.c_str());
+
// Add an entry into the cache
std::string ltname = lname;
ltname += "_LIBRARY_TYPE";
@@ -1133,6 +1154,26 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName,
cmTargets::iterator it =
m_Targets.insert(cmTargets::value_type(exeName,target)).first;
+ // set the LOCATION property of the target
+ std::string target_location;
+ target_location = this->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
+ if ( target_location.size() == 0 )
+ {
+ target_location += this->GetCurrentOutputDirectory();
+ }
+ if ( target_location.size() > 0 )
+ {
+ target_location += "/";
+ }
+ const char* cfgid = this->GetDefinition("CMAKE_CFG_INTDIR");
+ if ( cfgid && strcmp(cfgid, ".") != 0 )
+ {
+ target_location += cfgid;
+ target_location += "/";
+ }
+ target_location += target.GetFullName(this);
+ it->second.SetProperty("LOCATION",target_location.c_str());
+
// Add an entry into the cache
std::string exePath = exeName;
exePath += "_CMAKE_PATH";