diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2002-06-14 14:37:59 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2002-06-14 14:37:59 (GMT) |
commit | ab9c677232902ff966294672ab252a119265638c (patch) | |
tree | 39b493eb2885185a7c3b46562e114484ccff303c /Source/cmSystemTools.cxx | |
parent | 72bb1865c3e48e6d2353259bdc163a50cdf61304 (diff) | |
download | CMake-ab9c677232902ff966294672ab252a119265638c.zip CMake-ab9c677232902ff966294672ab252a119265638c.tar.gz CMake-ab9c677232902ff966294672ab252a119265638c.tar.bz2 |
ENH: FindLibrary can now use the makefile to add some compiler-specific lib search path (depending on the generator).
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 6db6e7a..4b69597 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -21,6 +21,7 @@ #include "cmRegularExpression.h" #include <ctype.h> #include "cmDirectory.h" +#include "cmMakefile.h" // support for realpath call #ifndef _WIN32 @@ -1547,7 +1548,8 @@ std::string cmSystemTools::FindProgram(const char* name, * found. Otherwise, the empty string is returned. */ std::string cmSystemTools::FindLibrary(const char* name, - const std::vector<std::string>& userPaths) + const std::vector<std::string>& userPaths, + const cmMakefile *makefile) { // See if the executable exists as written. if(cmSystemTools::FileExists(name)) @@ -1558,6 +1560,46 @@ std::string cmSystemTools::FindLibrary(const char* 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 + if (makefile) + { + const char* genName = makefile->GetDefinition("CMAKE_GENERATOR"); + if (genName) + { + if (!strcmp(genName, "NMake Makefiles") || + !strncmp(genName, "Visual Studio ", 14)) + { + const char* compiler = makefile->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, "Borland Makefiles")) + { + const char* bcb_bin_path = makefile->GetDefinition("BCB_BIN_PATH"); + if (bcb_bin_path) + { + std::string lib_path = + cmSystemTools::GetFilenamePath(bcb_bin_path) + "/Lib"; + path.push_back(lib_path); + } + } + } + } + std::string tryPath; for(std::vector<std::string>::const_iterator p = path.begin(); p != path.end(); ++p) |