diff options
author | Ken Martin <ken.martin@kitware.com> | 2001-06-21 16:01:18 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2001-06-21 16:01:18 (GMT) |
commit | 0ff3bdba204fec0671e601be5ff8b7af3ba821c8 (patch) | |
tree | f60e6e69d4d6a809340b5f7441ed29a4b4750495 /Source | |
parent | 8deccd3c2ea9d0eb5a63b2019a3dec984e7e0ae5 (diff) | |
download | CMake-0ff3bdba204fec0671e601be5ff8b7af3ba821c8.zip CMake-0ff3bdba204fec0671e601be5ff8b7af3ba821c8.tar.gz CMake-0ff3bdba204fec0671e601be5ff8b7af3ba821c8.tar.bz2 |
better install support
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmInstallFilesCommand.cxx | 57 | ||||
-rw-r--r-- | Source/cmInstallFilesCommand.h | 3 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 23 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 4 | ||||
-rw-r--r-- | Source/cmake.cxx | 12 |
5 files changed, 73 insertions, 26 deletions
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 97f9cfe..4de3110 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // cmExecutableCommand bool cmInstallFilesCommand::InitialPass(std::vector<std::string>& args) { - if(args.size() < 3) + if(args.size() < 2) { this->SetError("called with incorrect number of arguments"); return false; @@ -71,7 +71,13 @@ void cmInstallFilesCommand::FinalPass() std::string testf; std::string ext = m_FinalArgs[0]; - if (tgts.find("INSTALL") != tgts.end()) + if (tgts.find("INSTALL") == tgts.end()) + { + return; + } + + // two different options + if (m_FinalArgs.size() > 1) { // now put the files into the list std::vector<std::string>::iterator s = m_FinalArgs.begin(); @@ -84,24 +90,39 @@ void cmInstallFilesCommand::FinalPass() 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); - } - } + { + 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); - } + { + testf = temps + ext; + // add to the result + tgts["INSTALL"].GetSourceLists().push_back(testf); + } + } + } + else // reg exp list + { + std::vector<std::string> files; + cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(), + m_FinalArgs[0].c_str(), files); + + std::vector<std::string>::iterator s = files.begin(); + // for each argument, get the files + for (;s != files.end(); ++s) + { + tgts["INSTALL"].GetSourceLists().push_back(*s); } } } + + diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index f5a764d..0f86d88 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -95,7 +95,8 @@ public: { 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..."; + "INSTALL_FILES(path regexp)\n" + "Create rules to install the listed files into the path. Path is relative to the variable CMAKE_INSTALL_PREFIX. There are two forms for this command. In the first 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... In the second form any files in the current directory that match the regular expression will be installed."; } cmTypeMacro(cmInstallFilesCommand, cmCommand); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index bbbd3a3..5d3864c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <sys/stat.h> #include "cmRegularExpression.h" #include <ctype.h> +#include "cmDirectory.h" #if defined(_MSC_VER) || defined(__BORLANDC__) #include <windows.h> @@ -1064,3 +1065,25 @@ std::string cmSystemTools::GetFilenameNameWithoutExtension(const std::string& fi } } + +void cmSystemTools::Glob(const char *directory, const char *regexp, + std::vector<std::string>& files) +{ + cmDirectory d; + cmRegularExpression reg(regexp); + + if (d.Load(directory)) + { + int i, numf; + numf = d.GetNumberOfFiles(); + for (i = 0; i < numf; i++) + { + std::string fname = d.GetFile(i); + if (reg.find(fname)) + { + files.push_back(fname); + } + } + } +} + diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index e404168..8ea7724 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -204,7 +204,9 @@ public: ///! return true if the file is a directory. static bool FileIsDirectory(const char* name); - + static void Glob(const char *directory, const char *regexp, + std::vector<std::string>& files); + static std::string GetCurrentWorkingDirectory(); static std::string GetProgramPath(const char*); static void SplitProgramPath(const char* in_name, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 7e2a14b..f015024 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -157,19 +157,19 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args) cMakeRoot = cMakeRoot.substr(0, slashPos); } // is there no Modules direcory there? - std::string modules = cMakeRoot + "/Modules"; - if (!cmSystemTools::FileIsDirectory(modules.c_str())) + std::string modules = cMakeRoot + "/Modules/FindVTK.cmake"; + if (!cmSystemTools::FileExists(modules.c_str())) { // try exe/../share/cmake - modules = cMakeRoot + "/share/CMake/Modules"; - if (!cmSystemTools::FileIsDirectory(modules.c_str())) + modules = cMakeRoot + "/share/CMake/Modules/FindVTK.cmake"; + if (!cmSystemTools::FileExists(modules.c_str())) { #ifdef CMAKE_ROOT_DIR // try compiled in value on UNIX cMakeRoot = CMAKE_ROOT_DIR; - modules = cMakeRoot + "/Modules"; + modules = cMakeRoot + "/Modules/FindVTK.cmake"; #endif - if (!cmSystemTools::FileIsDirectory(modules.c_str())) + if (!cmSystemTools::FileExists(modules.c_str())) { // couldn't find modules cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n", |