summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-02-10 18:54:36 (GMT)
committerBrad King <brad.king@kitware.com>2006-02-10 18:54:36 (GMT)
commitb8a33fb424aa28b710e0ec170814ac380ee057db (patch)
tree23c06b61601d90d4703271fed4f90d2d3df7fee7 /Source
parentd2621064e27e38eba984c994746eaee40bc09ebc (diff)
downloadCMake-b8a33fb424aa28b710e0ec170814ac380ee057db.zip
CMake-b8a33fb424aa28b710e0ec170814ac380ee057db.tar.gz
CMake-b8a33fb424aa28b710e0ec170814ac380ee057db.tar.bz2
ENH: Added INSTALL command as a placeholder for a future generic install specification interface. Currently it supports only a SCRIPT option specifying a script to run during the install stage.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmInstallCommand.cxx54
-rw-r--r--Source/cmInstallCommand.h80
-rw-r--r--Source/cmLocalGenerator.cxx9
-rw-r--r--Source/cmMakefile.h10
5 files changed, 154 insertions, 1 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 88b06c2..22d4e32 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -26,6 +26,7 @@
#include "cmGetDirectoryPropertyCommand.cxx"
#include "cmGetTestPropertyCommand.cxx"
#include "cmIncludeExternalMSProjectCommand.cxx"
+#include "cmInstallCommand.cxx"
#include "cmLinkLibrariesCommand.cxx"
#include "cmLoadCacheCommand.cxx"
#include "cmMathCommand.cxx"
@@ -68,6 +69,7 @@ void GetPredefinedCommands(std::list<cmCommand*>&
commands.push_back(new cmGetDirectoryPropertyCommand);
commands.push_back(new cmGetTestPropertyCommand);
commands.push_back(new cmIncludeExternalMSProjectCommand);
+ commands.push_back(new cmInstallCommand);
commands.push_back(new cmLinkLibrariesCommand);
commands.push_back(new cmLoadCacheCommand);
commands.push_back(new cmLoadCommandCommand);
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
new file mode 100644
index 0000000..97f12ca
--- /dev/null
+++ b/Source/cmInstallCommand.cxx
@@ -0,0 +1,54 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "cmInstallCommand.h"
+
+// cmInstallCommand
+bool cmInstallCommand::InitialPass(std::vector<std::string> const& args)
+{
+ bool doing_script = false;
+ for(size_t i=0; i < args.size(); ++i)
+ {
+ if(args[i] == "SCRIPT")
+ {
+ doing_script = true;
+ }
+ else if(doing_script)
+ {
+ doing_script = false;
+ std::string script = args[i];
+ if(!cmSystemTools::FileIsFullPath(script.c_str()))
+ {
+ script = m_Makefile->GetCurrentDirectory();
+ script += "/";
+ script += args[i];
+ }
+ if(cmSystemTools::FileIsDirectory(script.c_str()))
+ {
+ this->SetError("given a directory as value of SCRIPT argument.");
+ return false;
+ }
+ m_Makefile->AddInstallScript(script.c_str());
+ }
+ }
+ if(doing_script)
+ {
+ this->SetError("given no value for SCRIPT argument.");
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h
new file mode 100644
index 0000000..789cc79
--- /dev/null
+++ b/Source/cmInstallCommand.h
@@ -0,0 +1,80 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef cmInstallCommand_h
+#define cmInstallCommand_h
+
+#include "cmCommand.h"
+
+/** \class cmInstallCommand
+ * \brief Specifies where to install some files
+ *
+ * cmInstallCommand is a general-purpose interface command for
+ * specifying install rules.
+ */
+class cmInstallCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmInstallCommand;
+ }
+
+ /**
+ * This is called when the command is first encountered in
+ * the CMakeLists.txt file.
+ */
+ virtual bool InitialPass(std::vector<std::string> const& args);
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual const char* GetName() { return "INSTALL";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Install rule specification interface command.";
+ }
+
+ /**
+ * More documentation.
+ */
+ virtual const char* GetFullDocumentation()
+ {
+ return
+ " INSTALL(SCRIPT <script1> [SCRIPT <script2> [...]])\n"
+ "Specify rules to run at install time. If SCRIPT is given the "
+ "file named after it will be included in the install scripts. "
+ "Multiple SCRIPTs may be given within a single source directory "
+ "and the scripts will be run in the order given. "
+ "The processing order of these scripts relative to install rules "
+ "generated by INSTALL_TARGETS, INSTALL_FILES, and INSTALL_PROGRAMS "
+ "commands is not specified.\n"
+ "This command is a placeholder for a future larger interface."
+ ;
+ }
+
+ cmTypeMacro(cmInstallCommand, cmCommand);
+};
+
+
+#endif
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 04ae274..4a95ca1 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -354,6 +354,15 @@ void cmLocalGenerator::GenerateInstallRules()
exeOutPath = currdir + "/";
}
+ // Include user-specified install scripts.
+ std::vector<std::string> const& installScripts =
+ m_Makefile->GetInstallScripts();
+ for(std::vector<std::string>::const_iterator s = installScripts.begin();
+ s != installScripts.end(); ++s)
+ {
+ fout << "INCLUDE(\"" << s->c_str() << "\")" << std::endl;
+ }
+
std::string destination;
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index f6418ba..cdd0adc 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -671,7 +671,12 @@ public:
///! Set/Get the preorder flag
void SetPreOrder(bool p) { this->PreOrder = p; }
bool GetPreOrder() { return this->PreOrder; }
-
+
+ /** Add a script file to be invoked during installation. */
+ void AddInstallScript(const char* script)
+ { m_InstallScripts.push_back(script); }
+ std::vector<std::string> const& GetInstallScripts()
+ { return m_InstallScripts; }
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(const char* name, cmTarget& target);
@@ -704,6 +709,9 @@ protected:
cmTarget::LinkLibraries m_LinkLibraries;
+ // List of install-time scripts. This should not be inherited.
+ std::vector<std::string> m_InstallScripts;
+
std::string m_IncludeFileRegularExpression;
std::string m_ComplainFileRegularExpression;
std::vector<std::string> m_SourceFileExtensions;