summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmCommands.cxx4
-rw-r--r--Source/cmInstallFilesCommand.cxx107
-rw-r--r--Source/cmInstallFilesCommand.h108
-rw-r--r--Source/cmInstallTargetsCommand.cxx66
-rw-r--r--Source/cmInstallTargetsCommand.h98
-rw-r--r--Source/cmTarget.cxx6
-rw-r--r--Source/cmTarget.h13
7 files changed, 400 insertions, 2 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 91872fa..ad2c57e 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -39,6 +39,8 @@
#include "cmIncludeCommand.cxx"
#include "cmIncludeDirectoryCommand.cxx"
#include "cmIncludeRegularExpressionCommand.cxx"
+#include "cmInstallFilesCommand.cxx"
+#include "cmInstallTargetsCommand.cxx"
#include "cmLinkDirectoriesCommand.cxx"
#include "cmLinkLibrariesCommand.cxx"
#include "cmLoadCacheCommand.cxx"
@@ -93,6 +95,8 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmIncludeCommand);
commands.push_back(new cmIncludeDirectoryCommand);
commands.push_back(new cmIncludeRegularExpressionCommand);
+ commands.push_back(new cmInstallFilesCommand);
+ commands.push_back(new cmInstallTargetsCommand);
commands.push_back(new cmLinkDirectoriesCommand);
commands.push_back(new cmLinkLibrariesCommand);
commands.push_back(new cmLoadCacheCommand);
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
new file mode 100644
index 0000000..ce084be
--- /dev/null
+++ b/Source/cmInstallFilesCommand.cxx
@@ -0,0 +1,107 @@
+/*=========================================================================
+
+ 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 "cmInstallFilesCommand.h"
+#include "cmCacheManager.h"
+
+// cmExecutableCommand
+bool cmInstallFilesCommand::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 3)
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ cmTargets &tgts = m_Makefile->GetTargets();
+ std::vector<std::string>::iterator s = args.begin();
+ if (tgts.find("INSTALL") != tgts.end())
+ {
+ tgts["INSTALL"].SetInstallPath(args[0].c_str());
+ }
+ ++s;
+ for (;s != args.end(); ++s)
+ {
+ m_FinalArgs.push_back(*s);
+ }
+
+ return true;
+}
+
+void cmInstallFilesCommand::FinalPass()
+{
+ cmTargets &tgts = m_Makefile->GetTargets();
+ std::string testf;
+ std::string ext = m_FinalArgs[0];
+
+ if (tgts.find("INSTALL") != tgts.end())
+ {
+ // now put the files into the list
+ std::vector<std::string>::iterator s = m_FinalArgs.begin();
+ ++s;
+ // for each argument, get the files
+ for (;s != m_FinalArgs.end(); ++s)
+ {
+ // replace any variables
+ std::string temps = *s;
+ m_Makefile->ExpandVariablesInString(temps);
+ // look for a srclist
+ if (m_Makefile->GetSources().find(temps) != m_Makefile->GetSources().end())
+ {
+ const std::vector<cmSourceFile> &clsList =
+ m_Makefile->GetSources().find(temps)->second;
+ std::vector<cmSourceFile>::const_iterator c = clsList.begin();
+ for (; c != clsList.end(); ++c)
+ {
+ testf = c->GetSourceName() + ext;
+ // add to the result
+ tgts["INSTALL"].GetSourceLists().push_back(testf);
+ }
+ }
+ // if one wasn't found then assume it is a single class
+ else
+ {
+ testf = temps + ext;
+ // add to the result
+ tgts["INSTALL"].GetSourceLists().push_back(testf);
+ }
+ }
+ }
+}
diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h
new file mode 100644
index 0000000..e304edb
--- /dev/null
+++ b/Source/cmInstallFilesCommand.h
@@ -0,0 +1,108 @@
+/*=========================================================================
+
+ 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 cmInstallFilesCommand_h
+#define cmInstallFilesCommand_h
+
+#include "cmStandardIncludes.h"
+#include "cmCommand.h"
+
+/** \class cmInstallFilesCommand
+ * \brief Specifies where to install some files
+ *
+ * cmInstallFilesCommand specifies the relative path where a list of
+ * files should be installed.
+ */
+class cmInstallFilesCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmInstallFilesCommand;
+ }
+
+ /**
+ * 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 "INSTALL_FILES";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Create install rules for files";
+ }
+
+ /**
+ * This is called at the end after all the information
+ * specified by the command is accumulated. Most commands do
+ * not implement this method. At this point, reading and
+ * writing to the cache can be done.
+ */
+ virtual void FinalPass();
+
+ /**
+ * More documentation.
+ */
+ virtual const char* GetFullDocumentation()
+ {
+ return
+ "INSTALL_FILES(path extension srclist file file srclist ...)\n"
+ "Create rules to install the listed files into the path. Path is relative to the variable PREFIX. The files can be specified explicitly or by referenceing source lists. All files must either have the extension specified or exist with the extension appended. A typical extension is .h etc...";
+ }
+
+ cmTypeMacro(cmInstallFilesCommand, cmCommand);
+
+ private:
+ std::vector<std::string> m_FinalArgs;
+};
+
+
+#endif
diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx
new file mode 100644
index 0000000..68724a5
--- /dev/null
+++ b/Source/cmInstallTargetsCommand.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 "cmInstallTargetsCommand.h"
+#include "cmCacheManager.h"
+
+// cmExecutableCommand
+bool cmInstallTargetsCommand::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 2 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ cmTargets &tgts = m_Makefile->GetTargets();
+ std::vector<std::string>::iterator s = args.begin();
+ ++s;
+ for (;s != args.end(); ++s)
+ {
+ if (tgts.find(*s) != tgts.end())
+ {
+ tgts[*s].SetInstallPath(args[0].c_str());
+ }
+ }
+
+ return true;
+}
+
diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h
new file mode 100644
index 0000000..b661edf
--- /dev/null
+++ b/Source/cmInstallTargetsCommand.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 cmInstallTargetsCommand_h
+#define cmInstallTargetsCommand_h
+
+#include "cmStandardIncludes.h"
+#include "cmCommand.h"
+
+/** \class cmInstallTargetsCommand
+ * \brief Specifies where to install some targets
+ *
+ * cmInstallTargetsCommand specifies the relative path where a list of
+ * targets should be installed. The targets can be executables or
+ * libraries.
+ */
+class cmInstallTargetsCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmInstallTargetsCommand;
+ }
+
+ /**
+ * 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 "INSTALL_TARGETS";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Create install rules for targets";
+ }
+
+ /**
+ * More documentation.
+ */
+ virtual const char* GetFullDocumentation()
+ {
+ return
+ "INSTALL_TARGETS(path target target)\n"
+ "Create rules to install the listed targets into the path. Path is relative to the variable PREFIX";
+ }
+
+ cmTypeMacro(cmInstallTargetsCommand, cmCommand);
+};
+
+
+#endif
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 77d0cce..2472b34 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -43,6 +43,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
void cmTarget::GenerateSourceFilesFromSourceLists(const cmMakefile &mf)
{
+ // this is only done for non install targets
+ if (this->m_TargetType == cmTarget::INSTALL)
+ {
+ return;
+ }
+
// for each src lists add the classes
for (std::vector<std::string>::const_iterator s = m_SourceLists.begin();
s != m_SourceLists.end(); ++s)
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a0faf69..5e8c989 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -54,7 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class cmTarget
{
public:
- enum TargetType { EXECUTABLE, WIN32_EXECUTABLE, LIBRARY, UTILITY };
+ enum TargetType { EXECUTABLE, WIN32_EXECUTABLE, LIBRARY, UTILITY, INSTALL };
+
/**
* Return the type of target.
*/
@@ -99,9 +100,16 @@ public:
typedef std::vector<std::pair<std::string,LinkLibraryType> > LinkLibraries;
const LinkLibraries &GetLinkLibraries() const {return m_LinkLibraries;}
LinkLibraries &GetLinkLibraries() {return m_LinkLibraries;}
+
+ /**
+ * Set the path where this target should be installed. This is relative to
+ * INSTALL_PREFIX
+ */
+ std::string GetInstallPath() const {return m_InstallPath;}
+ void SetInstallPath(const char *name) {m_InstallPath = name;}
/**
- * Merge Link LIbraries into this targets current list
+ * Merge Link Libraries into this targets current list
*/
void MergeLibraries(const LinkLibraries &ll);
@@ -118,6 +126,7 @@ private:
std::vector<cmSourceFile> m_SourceFiles;
LinkLibraries m_LinkLibraries;
bool m_InAll;
+ std::string m_InstallPath;
};
typedef std::map<std::string,cmTarget> cmTargets;