diff options
author | Ken Martin <ken.martin@kitware.com> | 2002-12-02 20:59:59 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2002-12-02 20:59:59 (GMT) |
commit | 9e526f797ae544fadc8a4289d6c4f06a0770342b (patch) | |
tree | 4cb87a3d59c7cc6c436ce2997e94030248257844 /Source/cmMakefile.cxx | |
parent | 82a01df535c9434787abcc26881986d85052adf7 (diff) | |
download | CMake-9e526f797ae544fadc8a4289d6c4f06a0770342b.zip CMake-9e526f797ae544fadc8a4289d6c4f06a0770342b.tar.gz CMake-9e526f797ae544fadc8a4289d6c4f06a0770342b.tar.bz2 |
removed cmMakefile depend from cmSystemTools
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 912b2fb..7aad788 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1459,3 +1459,79 @@ void cmMakefile::DisplayStatus(const char* message, float s) this->GetLocalGenerator()->GetGlobalGenerator() ->GetCMakeInstance()->UpdateProgress(message, s); } + +/** + * Find the library with the given name. Searches the given path and then + * the system search path. Returns the full path to the library if it is + * found. Otherwise, the empty string is returned. + */ +std::string cmMakefile::FindLibrary(const char* name, + const std::vector<std::string>& userPaths) +{ + // See if the executable exists as written. + if(cmSystemTools::FileExists(name)) + { + return cmSystemTools::CollapseFullPath(name); + } + + // Add the system search path to our path. + std::vector<std::string> path = userPaths; + cmSystemTools::GetPath(path); + + // Add some lib directories specific to compilers, depending on the + // current generator, so that library that might have been stored here + // can be found too. + // i.e. Microsoft Visual Studio or .Net: path to compiler/../Lib + // Borland: path to compiler/../Lib + const char* genName = this->GetDefinition("CMAKE_GENERATOR"); + if (genName) + { + if (!strcmp(genName, "NMake Makefiles") || + !strcmp(genName, "Visual Studio 6")) + { + const char* compiler = this->GetDefinition("CMAKE_CXX_COMPILER"); + if (compiler) + { + std::string compiler_path = cmSystemTools::FindProgram(compiler); + if (compiler_path.size()) + { + std::string lib_path = + cmSystemTools::GetFilenamePath( + cmSystemTools::GetFilenamePath(compiler_path)) + "/Lib"; + path.push_back(lib_path); + } + } + } + else if (!strcmp(genName, "Visual Studio 7")) + { + // It is likely that the compiler won't be in the path for .Net, but + // we know where devenv is. + const char* devenv = this->GetDefinition("MICROSOFT_DEVENV"); + if (devenv) + { + std::string devenv_path = cmSystemTools::FindProgram(devenv); + if (devenv_path.size()) + { + std::string vc7_path = + cmSystemTools::GetFilenamePath( + cmSystemTools::GetFilenamePath( + cmSystemTools::GetFilenamePath(devenv_path))) + "/Vc7"; + path.push_back(vc7_path + "/lib"); + path.push_back(vc7_path + "/PlatformSDK/lib"); + } + } + } + else if (!strcmp(genName, "Borland Makefiles")) + { + const char* bcb_bin_path = this->GetDefinition("BCB_BIN_PATH"); + if (bcb_bin_path) + { + std::string lib_path = + cmSystemTools::GetFilenamePath(bcb_bin_path) + "/Lib"; + path.push_back(lib_path); + } + } + } + + return cmSystemTools::FindLibrary(name, path); +} |