summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-07-31 15:29:21 (GMT)
committerBrad King <brad.king@kitware.com>2001-07-31 15:29:21 (GMT)
commitcfa25e9e1a48938378c300dfbf5b33e62018f295 (patch)
tree146a67f93597b35e69c38255aaddbd0547b19f81
parent489e91a1f7b1d5d9542cb965b47a44f99878c7a5 (diff)
downloadCMake-cfa25e9e1a48938378c300dfbf5b33e62018f295.zip
CMake-cfa25e9e1a48938378c300dfbf5b33e62018f295.tar.gz
CMake-cfa25e9e1a48938378c300dfbf5b33e62018f295.tar.bz2
ENH: Added INSTALL_PROGRAMS command and corresponding support. This involved splitting cmTarget::INSTALL into INSTALL_FILES and INSTALL_PROGRAMS enum values. INSTALL_FILES no longer adds execute permission. The INSTALL_PROGRAMS commnad takes either a list of explicit names, or a regex. It will not expand source lists like the INSTALL_FILES command will.
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmDSPWriter.cxx7
-rw-r--r--Source/cmDSWWriter.cxx3
-rw-r--r--Source/cmInstallFilesCommand.cxx12
-rw-r--r--Source/cmInstallProgramsCommand.cxx106
-rw-r--r--Source/cmInstallProgramsCommand.h109
-rw-r--r--Source/cmMakefile.cxx8
-rw-r--r--Source/cmTarget.cxx3
-rw-r--r--Source/cmTarget.h2
-rw-r--r--Source/cmUnixMakefileGenerator.cxx46
-rw-r--r--Templates/CMakeLists.txt3
11 files changed, 283 insertions, 18 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 6f474e7..bebf2ca 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -33,6 +33,7 @@
#include "cmIncludeDirectoryCommand.cxx"
#include "cmIncludeRegularExpressionCommand.cxx"
#include "cmInstallFilesCommand.cxx"
+#include "cmInstallProgramsCommand.cxx"
#include "cmInstallTargetsCommand.cxx"
#include "cmLinkDirectoriesCommand.cxx"
#include "cmLinkLibrariesCommand.cxx"
@@ -87,6 +88,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmIncludeDirectoryCommand);
commands.push_back(new cmIncludeRegularExpressionCommand);
commands.push_back(new cmInstallFilesCommand);
+ commands.push_back(new cmInstallProgramsCommand);
commands.push_back(new cmInstallTargetsCommand);
commands.push_back(new cmLinkDirectoriesCommand);
commands.push_back(new cmLinkLibrariesCommand);
diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx
index eff7bf1..67f1890 100644
--- a/Source/cmDSPWriter.cxx
+++ b/Source/cmDSPWriter.cxx
@@ -114,13 +114,16 @@ void cmDSPWriter::OutputDSPFile()
case cmTarget::UTILITY:
this->SetBuildType(UTILITY, l->first.c_str());
break;
- case cmTarget::INSTALL:
+ case cmTarget::INSTALL_FILES:
+ break;
+ case cmTarget::INSTALL_PROGRAMS:
break;
default:
cmSystemTools::Error("Bad target type", l->first.c_str());
break;
}
- if (l->second.GetType() != cmTarget::INSTALL)
+ if ((l->second.GetType() != cmTarget::INSTALL_FILES)
+ && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
this->CreateSingleDSP(l->first.c_str(),l->second);
}
diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx
index 3662f28..92cc9d4 100644
--- a/Source/cmDSWWriter.cxx
+++ b/Source/cmDSWWriter.cxx
@@ -171,7 +171,8 @@ void cmDSWWriter::WriteDSWFile(std::ostream& fout)
}
}
// Write the project into the DSW file
- if (l->second.GetType() != cmTarget::INSTALL)
+ if ((l->second.GetType() != cmTarget::INSTALL_FILES)
+ && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
this->WriteProject(fout, si->c_str(), dir.c_str(),
pg->GetDSPWriter(),l->second);
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 4de3110..d7f68e5 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -52,9 +52,9 @@ bool cmInstallFilesCommand::InitialPass(std::vector<std::string>& args)
cmTargets &tgts = m_Makefile->GetTargets();
std::vector<std::string>::iterator s = args.begin();
- if (tgts.find("INSTALL") != tgts.end())
+ if (tgts.find("INSTALL_FILES") != tgts.end())
{
- tgts["INSTALL"].SetInstallPath(args[0].c_str());
+ tgts["INSTALL_FILES"].SetInstallPath(args[0].c_str());
}
++s;
for (;s != args.end(); ++s)
@@ -71,7 +71,7 @@ void cmInstallFilesCommand::FinalPass()
std::string testf;
std::string ext = m_FinalArgs[0];
- if (tgts.find("INSTALL") == tgts.end())
+ if (tgts.find("INSTALL_FILES") == tgts.end())
{
return;
}
@@ -98,7 +98,7 @@ void cmInstallFilesCommand::FinalPass()
{
testf = c->GetSourceName() + ext;
// add to the result
- tgts["INSTALL"].GetSourceLists().push_back(testf);
+ tgts["INSTALL_FILES"].GetSourceLists().push_back(testf);
}
}
// if one wasn't found then assume it is a single class
@@ -106,7 +106,7 @@ void cmInstallFilesCommand::FinalPass()
{
testf = temps + ext;
// add to the result
- tgts["INSTALL"].GetSourceLists().push_back(testf);
+ tgts["INSTALL_FILES"].GetSourceLists().push_back(testf);
}
}
}
@@ -120,7 +120,7 @@ void cmInstallFilesCommand::FinalPass()
// for each argument, get the files
for (;s != files.end(); ++s)
{
- tgts["INSTALL"].GetSourceLists().push_back(*s);
+ tgts["INSTALL_FILES"].GetSourceLists().push_back(*s);
}
}
}
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
new file mode 100644
index 0000000..e8fac31
--- /dev/null
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -0,0 +1,106 @@
+/*=========================================================================
+
+ 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 "cmInstallProgramsCommand.h"
+#include "cmCacheManager.h"
+
+// cmExecutableCommand
+bool cmInstallProgramsCommand::InitialPass(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();
+ if (tgts.find("INSTALL_PROGRAMS") != tgts.end())
+ {
+ tgts["INSTALL_PROGRAMS"].SetInstallPath(args[0].c_str());
+ }
+ ++s;
+ for (;s != args.end(); ++s)
+ {
+ m_FinalArgs.push_back(*s);
+ }
+
+ return true;
+}
+
+void cmInstallProgramsCommand::FinalPass()
+{
+ cmTargets &tgts = m_Makefile->GetTargets();
+
+ if (tgts.find("INSTALL_PROGRAMS") == tgts.end())
+ {
+ return;
+ }
+
+ // two different options
+ if (m_FinalArgs.size() > 1)
+ {
+ // for each argument, get the programs
+ for (std::vector<std::string>::iterator s = m_FinalArgs.begin();
+ s != m_FinalArgs.end(); ++s)
+ {
+ // replace any variables
+ std::string temps = *s;
+ m_Makefile->ExpandVariablesInString(temps);
+ // add to the result
+ tgts["INSTALL_PROGRAMS"].GetSourceLists().push_back(temps);
+ }
+ }
+ else // reg exp list
+ {
+ std::vector<std::string> programs;
+ cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(),
+ m_FinalArgs[0].c_str(), programs);
+
+ std::vector<std::string>::iterator s = programs.begin();
+ // for each argument, get the programs
+ for (;s != programs.end(); ++s)
+ {
+ tgts["INSTALL_PROGRAMS"].GetSourceLists().push_back(*s);
+ }
+ }
+}
+
+
diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h
new file mode 100644
index 0000000..4c5c370
--- /dev/null
+++ b/Source/cmInstallProgramsCommand.h
@@ -0,0 +1,109 @@
+/*=========================================================================
+
+ 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 cmInstallProgramsCommand_h
+#define cmInstallProgramsCommand_h
+
+#include "cmStandardIncludes.h"
+#include "cmCommand.h"
+
+/** \class cmInstallProgramsCommand
+ * \brief Specifies where to install some programs
+ *
+ * cmInstallProgramsCommand specifies the relative path where a list of
+ * programs should be installed.
+ */
+class cmInstallProgramsCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmInstallProgramsCommand;
+ }
+
+ /**
+ * This is called when the command is first encountered in
+ * the CMakeLists.txt file.
+ */
+ virtual bool InitialPass(std::vector<std::string>& args);
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual const char* GetName() { return "INSTALL_PROGRAMS";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Create install rules for programs";
+ }
+
+ /**
+ * 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_PROGRAMS(path file file ...)\n"
+ "INSTALL_PROGRAMS(path regexp)\n"
+ "Create rules to install the listed programs into the path. Path is relative to the variable CMAKE_INSTALL_PREFIX. There are two forms for this command. In the first the programs can be specified explicitly. In the second form any program in the current directory that match the regular expression will be installed.";
+ }
+
+ cmTypeMacro(cmInstallProgramsCommand, cmCommand);
+
+ private:
+ std::vector<std::string> m_FinalArgs;
+};
+
+
+#endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 19cc386..a509de8 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -122,11 +122,13 @@ void cmMakefile::AddDefaultCommands()
#if defined(__APPLE__)
this->AddDefinition("APPLE", "1");
#endif
- // always creat an empty install target
+ // always creat an empty install targets for files and programs.
cmTarget target;
- target.SetType(cmTarget::INSTALL);
target.SetInAll(false);
- m_Targets.insert(cmTargets::value_type("INSTALL",target));
+ target.SetType(cmTarget::INSTALL_FILES);
+ m_Targets.insert(cmTargets::value_type("INSTALL_FILES", target));
+ target.SetType(cmTarget::INSTALL_PROGRAMS);
+ m_Targets.insert(cmTargets::value_type("INSTALL_PROGRAMS", target));
}
cmMakefile::~cmMakefile()
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ea983f9..8fc06ea 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -44,7 +44,8 @@ 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)
+ if ((this->m_TargetType == cmTarget::INSTALL_FILES)
+ || (this->m_TargetType == cmTarget::INSTALL_PROGRAMS))
{
return;
}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 4b8e612..e7946a6 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -55,7 +55,7 @@ class cmTarget
{
public:
enum TargetType { EXECUTABLE, WIN32_EXECUTABLE, STATIC_LIBRARY,
- SHARED_LIBRARY, UTILITY, INSTALL };
+ SHARED_LIBRARY, UTILITY, INSTALL_FILES, INSTALL_PROGRAMS };
/**
* Return the type of target.
diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx
index 966db4a..225cd33 100644
--- a/Source/cmUnixMakefileGenerator.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -1042,7 +1042,7 @@ void cmUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
<< cmSystemTools::GetExecutableExtension()
<< " " << prefix << l->second.GetInstallPath() << "\n";
break;
- case cmTarget::INSTALL:
+ case cmTarget::INSTALL_FILES:
{
const std::vector<std::string> &sf = l->second.GetSourceLists();
std::vector<std::string>::const_iterator i;
@@ -1058,7 +1058,7 @@ void cmUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
}
else
{
- fout << "\t $(INSTALL) ";
+ fout << "\t $(INSTALL_DATA) ";
}
fout << *i
<< " " << prefix << l->second.GetInstallPath() << "; \\\n";
@@ -1071,7 +1071,47 @@ void cmUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
}
else
{
- fout << "\t $(INSTALL) ";
+ fout << "\t $(INSTALL_DATA) ";
+ }
+ fout << "${srcdir}/" << *i
+ << " " << prefix << l->second.GetInstallPath() << "; \\\n";
+ fout << "\telse \\\n";
+ fout << "\t echo \" ERROR!!! Unable to find: " << *i
+ << " \"; \\\n";
+ fout << "\t fi\n";
+ }
+ }
+ break;
+ case cmTarget::INSTALL_PROGRAMS:
+ {
+ const std::vector<std::string> &sf = l->second.GetSourceLists();
+ std::vector<std::string>::const_iterator i;
+ for (i = sf.begin(); i != sf.end(); ++i)
+ {
+ fout << "\t@ echo \"Installing " << *i << " \"\n";
+ fout << "\t@if [ -f " << *i << " ] ; then \\\n";
+ // avoid using install-sh to install install-sh
+ // does not work on windows....
+ if(*i == "install-sh")
+ {
+ fout << "\t cp ";
+ }
+ else
+ {
+ fout << "\t $(INSTALL_PROGRAM) ";
+ }
+ fout << *i
+ << " " << prefix << l->second.GetInstallPath() << "; \\\n";
+ fout << "\t elif [ -f ${srcdir}/" << *i << " ] ; then \\\n";
+ // avoid using install-sh to install install-sh
+ // does not work on windows....
+ if(*i == "install-sh")
+ {
+ fout << "\t cp ";
+ }
+ else
+ {
+ fout << "\t $(INSTALL_PROGRAM) ";
}
fout << "${srcdir}/" << *i
<< " " << prefix << l->second.GetInstallPath() << "; \\\n";
diff --git a/Templates/CMakeLists.txt b/Templates/CMakeLists.txt
index f69f370..6c4c135 100644
--- a/Templates/CMakeLists.txt
+++ b/Templates/CMakeLists.txt
@@ -1,2 +1,3 @@
# just install the modules
-INSTALL_FILES(/share/CMake/Templates "" configure install-sh CMakeSystemConfig.cmake.in)
+INSTALL_FILES(/share/CMake/Templates "" CMakeSystemConfig.cmake.in)
+INSTALL_PROGRAMS(/share/CMake/Templates configure install-sh)