diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-05-09 12:25:45 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-05-09 12:25:45 (GMT) |
commit | 7f11536704d9f971cf5c8b0a2b490ccc6af58588 (patch) | |
tree | 05b5b24050a629bf9ceb59d743f77ca909448229 /Source/cmTarget.cxx | |
parent | 5af310502142252995ad5d74e66355be4094b7cc (diff) | |
download | CMake-7f11536704d9f971cf5c8b0a2b490ccc6af58588.zip CMake-7f11536704d9f971cf5c8b0a2b490ccc6af58588.tar.gz CMake-7f11536704d9f971cf5c8b0a2b490ccc6af58588.tar.bz2 |
ENH: now target names can be used in add_custom_command() and
add_custom_target() as COMMAND, and cmake will recognize them and replace
them with the actual output path of these executables. Also the dependency
will be added automatically. Test included.
ENH: moved TraceVSDependencies() to the end of GlobalGenerator::Configure(),
so it is done now in one central place
Alex
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 85f3d6e..9f99266 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -408,6 +408,31 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } + +void +cmTarget::checkForTargetsAsCommand(const std::vector<cmCustomCommand>& commands) +{ + for ( std::vector<cmCustomCommand>::const_iterator cli = commands.begin(); + cli != commands.end(); + ++cli ) + { + for ( cmCustomCommandLines::const_iterator cit=cli->GetCommandLines().begin(); + cit!=cli->GetCommandLines().end(); + ++cit ) + { + std::string command = *cit->begin(); + // see if we can find a target with this name + cmTarget* t = this->Makefile->GetLocalGenerator()-> + GetGlobalGenerator()->FindTarget ( 0, command.c_str() ); + if ( ( t ) && ( t->GetType() ==cmTarget::EXECUTABLE ) ) + { + this->AddUtility ( command.c_str() ); + } + } + } +} + + void cmTarget::TraceVSDependencies(std::string projFile, cmMakefile *makefile) { @@ -504,6 +529,11 @@ void cmTarget::TraceVSDependencies(std::string projFile, } } } + + checkForTargetsAsCommand(this->GetPreBuildCommands()); + checkForTargetsAsCommand(this->GetPreLinkCommands()); + checkForTargetsAsCommand(this->GetPostBuildCommands()); + while (!srcFilesToProcess.empty()) { // is this source the output of a custom command @@ -533,9 +563,28 @@ void cmTarget::TraceVSDependencies(std::string projFile, srcFilesQueued.insert(temp); } } + + // check if commands for this custom commands are names of targets and + // if that's the case add these targets as dependencies + std::vector<std::string> automaticTargetDepends; + for(cmCustomCommandLines::const_iterator it= + outsf->GetCustomCommand()->GetCommandLines().begin(); + it!=outsf->GetCustomCommand()->GetCommandLines().end(); + ++it) + { + const std::string& currentCommand = (*it)[0]; + // see if we can find a target with this name + cmTarget* t = this->Makefile->GetLocalGenerator()-> + GetGlobalGenerator()->FindTarget(0, currentCommand.c_str()); + if (( t) && (t->GetType()==cmTarget::EXECUTABLE)) + { + automaticTargetDepends.push_back(currentCommand); + } + } + outsf->GetCustomCommand()->AppendDepends(automaticTargetDepends); + // add its dependencies to the list to check - unsigned int i; - for (i = 0; i < outsf->GetCustomCommand()->GetDepends().size(); ++i) + for (unsigned int i = 0; i < outsf->GetCustomCommand()->GetDepends().size(); ++i) { const std::string& fullName = outsf->GetCustomCommand()->GetDepends()[i]; @@ -590,6 +639,7 @@ void cmTarget::TraceVSDependencies(std::string projFile, } } } + } // finished with this SF move to the next srcFilesToProcess.pop(); |