diff options
-rw-r--r-- | Source/cmAddCustomTargetCommand.cxx | 15 | ||||
-rw-r--r-- | Source/cmAddCustomTargetCommand.h | 3 | ||||
-rw-r--r-- | Source/cmAddTargetCommand.cxx | 66 | ||||
-rw-r--r-- | Source/cmAddTargetCommand.h | 98 | ||||
-rw-r--r-- | Source/cmDSWMakefile.cxx | 4 | ||||
-rw-r--r-- | Source/cmDSWWriter.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 18 | ||||
-rw-r--r-- | Source/cmMakefile.h | 8 | ||||
-rw-r--r-- | Source/cmTarget.h | 8 | ||||
-rw-r--r-- | Source/cmVTKWrapJavaCommand.cxx | 15 |
10 files changed, 226 insertions, 13 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index bbe15a2..ad3a0f4 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -43,16 +43,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // cmAddCustomTargetCommand bool cmAddCustomTargetCommand::Invoke(std::vector<std::string>& args) { + bool all = false; + if(args.size() < 2 ) { this->SetError("called with incorrect number of arguments"); return false; } - std::vector<std::string> dep; m_Makefile->ExpandVariablesInString(args[0]); m_Makefile->ExpandVariablesInString(args[1]); + + // all target option + if (args.size() >= 3) + { + if (args[2] == "ALL") + { + all = true; + } + } m_Makefile->AddUtilityCommand(args[0].c_str(), - args[1].c_str()); + args[1].c_str(), all); + return true; } diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index a82207d..d4cf520 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -90,7 +90,8 @@ public: virtual const char* GetFullDocumentation() { return - "ADD_CUSTOM_TARGET(Name \"command to run\")"; + "ADD_CUSTOM_TARGET(Name \"command to run\" ALL)\n" + "The ALL option is optional. If it is specified it indicates that this target should be added to the Build all target."; } cmTypeMacro(cmAddCustomTargetCommand, cmCommand); diff --git a/Source/cmAddTargetCommand.cxx b/Source/cmAddTargetCommand.cxx new file mode 100644 index 0000000..25f0797 --- /dev/null +++ b/Source/cmAddTargetCommand.cxx @@ -0,0 +1,66 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + +Copyright (c) 2001 Insight Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the Insight Consortium, nor the names of any consortium members, + nor of any contributors, may be used to endorse or promote products derived + from this software without specific prior written permission. + + * Modified source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=========================================================================*/ +#include "cmAddTargetCommand.h" + +// cmAddTargetCommand +bool cmAddTargetCommand::Invoke(std::vector<std::string>& args) +{ + bool all = false; + if(args.size() < 2 ) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + + // all target option + if (args.size() >= 3) + { + if (args[2] == "ALL") + { + all = true; + } + } + std::vector<std::string> dep; + m_Makefile->AddUtilityCommand(args[0].c_str(), + args[1].c_str(), all); + return true; +} + diff --git a/Source/cmAddTargetCommand.h b/Source/cmAddTargetCommand.h new file mode 100644 index 0000000..e52e24f --- /dev/null +++ b/Source/cmAddTargetCommand.h @@ -0,0 +1,98 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + +Copyright (c) 2001 Insight Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the Insight Consortium, nor the names of any consortium members, + nor of any contributors, may be used to endorse or promote products derived + from this software without specific prior written permission. + + * Modified source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=========================================================================*/ +#ifndef cmAddTargetCommand_h +#define cmAddTargetCommand_h + +#include "cmStandardIncludes.h" +#include "cmCommand.h" + +/** \class cmAddTargetCommand + * \brief Command that adds a target to the build system. + * + * cmAddTargetCommand adds an extra target to the build system. + * This is useful when you would like to add special + * targets like "install,", "clean," and so on. + */ +class cmAddTargetCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmAddTargetCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool Invoke(std::vector<std::string>& args); + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() + {return "ADD_TARGET";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Add an extra target to the build system."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + "ADD_TARGET(Name \"command to run\" ALL)\n" + "Add a target to the make process. The third argument ALL is optional. If it is specified then the target will be added to the all target." ; + } + + cmTypeMacro(cmAddTargetCommand, cmCommand); +}; + +#endif diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx index 723784a..f377780 100644 --- a/Source/cmDSWMakefile.cxx +++ b/Source/cmDSWMakefile.cxx @@ -95,7 +95,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout) allListFiles.push_back(m_Makefile); // add a special target that depends on ALL projects for easy build // of Debug only - m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\""); + m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"", false); m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles); // For each cmMakefile, create a DSP for it, and @@ -144,7 +144,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout) for(cmTargets::const_iterator al = atgts.begin(); al != atgts.end(); ++al) { - if(al->second.GetType() != cmTarget::UTILITY) + if(al->second.IsInAll()) { l->second.GetLinkLibraries().push_back( cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL)); diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx index 723784a..f377780 100644 --- a/Source/cmDSWWriter.cxx +++ b/Source/cmDSWWriter.cxx @@ -95,7 +95,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout) allListFiles.push_back(m_Makefile); // add a special target that depends on ALL projects for easy build // of Debug only - m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\""); + m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"", false); m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles); // For each cmMakefile, create a DSP for it, and @@ -144,7 +144,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout) for(cmTargets::const_iterator al = atgts.begin(); al != atgts.end(); ++al) { - if(al->second.GetType() != cmTarget::UTILITY) + if(al->second.IsInAll()) { l->second.GetLinkLibraries().push_back( cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL)); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0cfe265..9680064 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -482,12 +482,24 @@ void cmMakefile::AddExecutable(const char *exeName, void cmMakefile::AddUtilityCommand(const char* utilityName, - const char* command) + const char* command, + bool all) +{ + std::vector<std::string> empty; + this->AddUtilityCommand(utilityName,command,all, + empty,empty); +} + +void cmMakefile::AddUtilityCommand(const char* utilityName, + const char* command, + bool all, + const std::vector<std::string> &dep, + const std::vector<std::string> &out) { cmTarget target; target.SetType(cmTarget::UTILITY); - std::vector<std::string> empty; - cmCustomCommand cc(utilityName, command, empty, empty); + target.SetInAll(all); + cmCustomCommand cc(utilityName, command, dep, out); target.GetCustomCommands().push_back(cc); m_Targets.insert(cmTargets::value_type(utilityName,target)); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index ff60091..4823d36 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -140,7 +140,13 @@ public: * a command that is run every time a target is built. */ void AddUtilityCommand(const char* utilityName, - const char* command); + const char* command, + bool all); + void AddUtilityCommand(const char* utilityName, + const char* command, + bool all, + const std::vector<std::string> &depends, + const std::vector<std::string> &outputs); /** * Add a utility on which this project depends. A utility is an executable diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dd01521..8def255 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -66,6 +66,13 @@ public: void SetType(TargetType f) { m_TargetType = f; } /** + * Indicate whether the target is part of the all target + */ + bool IsInAll() const { return m_InAll; } + bool GetInAll() const { return m_InAll; } + void SetInAll(bool f) { m_InAll = f; } + + /** * Get the list of the custom commands for this target */ const std::vector<cmCustomCommand> &GetCustomCommands() const {return m_CustomCommands;} @@ -110,6 +117,7 @@ private: TargetType m_TargetType; std::vector<cmSourceFile> m_SourceFiles; LinkLibraries m_LinkLibraries; + bool m_InAll; }; typedef std::map<std::string,cmTarget> cmTargets; diff --git a/Source/cmVTKWrapJavaCommand.cxx b/Source/cmVTKWrapJavaCommand.cxx index d290b3a..b0d191e 100644 --- a/Source/cmVTKWrapJavaCommand.cxx +++ b/Source/cmVTKWrapJavaCommand.cxx @@ -104,6 +104,8 @@ void cmVTKWrapJavaCommand::FinalPass() int lastClass = m_WrapClasses.size(); std::vector<std::string> depends; std::vector<std::string> depends2; + std::vector<std::string> alldepends; + std::vector<std::string> empty; std::string wjava = "${VTK_WRAP_JAVA_EXE}"; std::string pjava = "${VTK_PARSE_JAVA_EXE}"; std::string hints = "${VTK_WRAP_HINTS}"; @@ -118,7 +120,8 @@ void cmVTKWrapJavaCommand::FinalPass() // wrap java std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx"; - std::string res2 = m_OriginalNames[classNum] + ".java"; + std::string res2 = resultDirectory + "/" + + m_OriginalNames[classNum] + ".java"; std::string cmd = wjava + " " + m_WrapHeaders[classNum] + " " + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx"; @@ -127,11 +130,19 @@ void cmVTKWrapJavaCommand::FinalPass() res.c_str(), m_LibraryName.c_str()); cmd = pjava + " " + m_WrapHeaders[classNum] + " " - + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + resultDirectory + "/" + m_OriginalNames[classNum] + ".java"; + + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + res2; m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(), cmd.c_str(), depends2, res2.c_str(), m_LibraryName.c_str()); + alldepends.push_back(res2); } + + m_Makefile->AddUtilityCommand((m_LibraryName+"JavaClasses").c_str(), + "", + true, + alldepends, + empty); + } |