summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2002-09-17 14:56:18 (GMT)
committerBrad King <brad.king@kitware.com>2002-09-17 14:56:18 (GMT)
commite5e0132203ab8b8c2391ad7847cf2204d1e44639 (patch)
tree30d559407bd0f6077ed040636d0d4b98400544aa /Source/cmLocalUnixMakefileGenerator.cxx
parent222b04f6d9a73d202faea473ab1c5c7991ca75e6 (diff)
downloadCMake-e5e0132203ab8b8c2391ad7847cf2204d1e44639.zip
CMake-e5e0132203ab8b8c2391ad7847cf2204d1e44639.tar.gz
CMake-e5e0132203ab8b8c2391ad7847cf2204d1e44639.tar.bz2
ENH: Improved implementation of INSTALL_FILES and INSTALL_PROGRAMS commands. Source paths can now be relative or full paths, and don't need to be in the same directory as the CMakeLists.txt file.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator.cxx74
1 files changed, 32 insertions, 42 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx
index 7abe109..09ccc2f 100644
--- a/Source/cmLocalUnixMakefileGenerator.cxx
+++ b/Source/cmLocalUnixMakefileGenerator.cxx
@@ -1664,81 +1664,71 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
break;
case cmTarget::INSTALL_FILES:
{
+ std::string sourcePath = m_Makefile->GetCurrentDirectory();
+ std::string binaryPath = m_Makefile->GetCurrentOutputDirectory();
+ sourcePath += "/";
+ binaryPath += "/";
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")
+ std::string f = *i;
+ if(f.substr(0, sourcePath.length()) == sourcePath)
{
- fout << "\t cp ";
+ f = f.substr(sourcePath.length());
}
- else
+ else if(f.substr(0, binaryPath.length()) == binaryPath)
{
- fout << "\t $(INSTALL_DATA) ";
+ f = f.substr(binaryPath.length());
}
- fout << *i
- << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "; \\\n";
- fout << "\t elif [ -f $(CMAKE_CURRENT_SOURCE)/" << *i << " ] ; then \\\n";
+ fout << "\t@ echo \"Installing " << f.c_str() << " \"\n";
// avoid using install-sh to install install-sh
- // does not work on windows....
- if(*i == "install-sh")
+ // does not work on windows....
+ if(*i == "install-sh")
{
- fout << "\t cp ";
+ fout << "\t @cp ";
}
else
{
- fout << "\t $(INSTALL_DATA) ";
+ fout << "\t @$(INSTALL_DATA) ";
}
- fout << "$(CMAKE_CURRENT_SOURCE)/" << *i
- << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "; \\\n";
- fout << "\telse \\\n";
- fout << "\t echo \" ERROR!!! Unable to find: " << *i
- << " \"; \\\n";
- fout << "\t fi\n";
+ fout << *i
+ << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
}
}
break;
case cmTarget::INSTALL_PROGRAMS:
{
+ std::string sourcePath = m_Makefile->GetCurrentDirectory();
+ std::string binaryPath = m_Makefile->GetCurrentOutputDirectory();
+ sourcePath += "/";
+ binaryPath += "/";
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")
+ std::string f = *i;
+ if(f.substr(0, sourcePath.length()) == sourcePath)
{
- fout << "\t cp ";
+ f = f.substr(sourcePath.length());
}
- else
+ else if(f.substr(0, binaryPath.length()) == binaryPath)
{
- fout << "\t $(INSTALL_PROGRAM) ";
+ f = f.substr(binaryPath.length());
}
- fout << *i
- << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "; \\\n";
- fout << "\t elif [ -f $(CMAKE_CURRENT_SOURCE)/" << *i << " ] ; then \\\n";
+ fout << "\t@ echo \"Installing " << f.c_str() << " \"\n";
// avoid using install-sh to install install-sh
- // does not work on windows....
- if(*i == "install-sh")
+ // does not work on windows....
+ if(*i == "install-sh")
{
- fout << "\t cp ";
+ fout << "\t @cp ";
}
else
{
- fout << "\t $(INSTALL_PROGRAM) ";
+ fout << "\t @$(INSTALL_DATA) ";
}
- fout << "$(CMAKE_CURRENT_SOURCE)/" << *i
- << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "; \\\n";
- fout << "\telse \\\n";
- fout << "\t echo \" ERROR!!! Unable to find: " << *i
- << " \"; \\\n";
- fout << "\t fi\n";
+ fout << *i
+ << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
}
}
break;