diff options
author | John Biddiscombe <jbiddiscombe@skippingmouse.co.uk> | 2001-09-11 23:58:22 (GMT) |
---|---|---|
committer | John Biddiscombe <jbiddiscombe@skippingmouse.co.uk> | 2001-09-11 23:58:22 (GMT) |
commit | ea40b86683c58325b8086650f2c7aac0a21ac02d (patch) | |
tree | 7fdadc9355591308992b9a2f6307ee7c449fd7b7 /Source/cmSystemTools.cxx | |
parent | faafcdddbf83e3efc96eb04fd80cce4c8514a5fa (diff) | |
download | CMake-ea40b86683c58325b8086650f2c7aac0a21ac02d.zip CMake-ea40b86683c58325b8086650f2c7aac0a21ac02d.tar.gz CMake-ea40b86683c58325b8086650f2c7aac0a21ac02d.tar.bz2 |
ENH: Add a findfile routine (as opposed to find executable or library) which doesn't
add any extensions - Borland make needs full paths to certain dependencies
otherwise linking doesn't work properly (dependencies aren't checked)
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 245b084..795208d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -923,8 +923,35 @@ std::string cmSystemTools::TemporaryFileName() risk of setting rights with 0666 */ return tempnam(0, "cmake"); } - +/** + * Find the file the given name. Searches the given path and then + * the system search path. Returns the full path to the file if it is + * found. Otherwise, the empty string is returned. + */ +std::string cmSystemTools::FindFile(const char* name, + const std::vector<std::string>& userPaths) +{ + // Add the system search path to our path. + std::vector<std::string> path = userPaths; + cmSystemTools::GetPath(path); + + std::string tryPath; + for(std::vector<std::string>::const_iterator p = path.begin(); + p != path.end(); ++p) + { + tryPath = *p; + tryPath += "/"; + tryPath += name; + if(cmSystemTools::FileExists(tryPath.c_str()) && + !cmSystemTools::FileIsDirectory(tryPath.c_str())) + { + return cmSystemTools::CollapseFullPath(tryPath.c_str()); + } + } + // Couldn't find the file. + return ""; +} /** * Find the executable with the given name. Searches the given path and then @@ -947,11 +974,11 @@ std::string cmSystemTools::FindProgram(const char* name, { return cmSystemTools::CollapseFullPath(tryPath.c_str()); } - + // Add the system search path to our path. std::vector<std::string> path = userPaths; cmSystemTools::GetPath(path); - + for(std::vector<std::string>::const_iterator p = path.begin(); p != path.end(); ++p) { @@ -970,7 +997,7 @@ std::string cmSystemTools::FindProgram(const char* name, return cmSystemTools::CollapseFullPath(tryPath.c_str()); } } - + // Couldn't find the program. return ""; } |