mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
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.
This commit is contained in:
parent
489e91a1f7
commit
cfa25e9e1a
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
106
Source/cmInstallProgramsCommand.cxx
Normal file
106
Source/cmInstallProgramsCommand.cxx
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
109
Source/cmInstallProgramsCommand.h
Normal file
109
Source/cmInstallProgramsCommand.h
Normal file
@ -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
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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";
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user