ENH: FindLibrary can now use the makefile to add some compiler-specific lib search path (depending on the generator).
This commit is contained in:
parent
72bb1865c3
commit
ab9c677232
|
@ -127,7 +127,8 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||||
i != names.end() ; ++i)
|
i != names.end() ; ++i)
|
||||||
{
|
{
|
||||||
library = cmSystemTools::FindLibrary(i->c_str(),
|
library = cmSystemTools::FindLibrary(i->c_str(),
|
||||||
path);
|
path,
|
||||||
|
m_Makefile);
|
||||||
if(library != "")
|
if(library != "")
|
||||||
{
|
{
|
||||||
m_Makefile->AddCacheDefinition(args[0].c_str(),
|
m_Makefile->AddCacheDefinition(args[0].c_str(),
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "cmRegularExpression.h"
|
#include "cmRegularExpression.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "cmDirectory.h"
|
#include "cmDirectory.h"
|
||||||
|
#include "cmMakefile.h"
|
||||||
|
|
||||||
// support for realpath call
|
// support for realpath call
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -1547,7 +1548,8 @@ std::string cmSystemTools::FindProgram(const char* name,
|
||||||
* found. Otherwise, the empty string is returned.
|
* found. Otherwise, the empty string is returned.
|
||||||
*/
|
*/
|
||||||
std::string cmSystemTools::FindLibrary(const char* name,
|
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.
|
// See if the executable exists as written.
|
||||||
if(cmSystemTools::FileExists(name))
|
if(cmSystemTools::FileExists(name))
|
||||||
|
@ -1558,6 +1560,46 @@ std::string cmSystemTools::FindLibrary(const char* name,
|
||||||
// Add the system search path to our path.
|
// Add the system search path to our path.
|
||||||
std::vector<std::string> path = userPaths;
|
std::vector<std::string> path = userPaths;
|
||||||
cmSystemTools::GetPath(path);
|
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;
|
std::string tryPath;
|
||||||
for(std::vector<std::string>::const_iterator p = path.begin();
|
for(std::vector<std::string>::const_iterator p = path.begin();
|
||||||
p != path.end(); ++p)
|
p != path.end(); ++p)
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
|
class cmMakefile;
|
||||||
|
|
||||||
/** \class cmSystemTools
|
/** \class cmSystemTools
|
||||||
* \brief A collection of useful functions for CMake.
|
* \brief A collection of useful functions for CMake.
|
||||||
*
|
*
|
||||||
|
@ -225,7 +227,8 @@ public:
|
||||||
|
|
||||||
///! Find a library in the system PATH, with optional extra paths.
|
///! Find a library in the system PATH, with optional extra paths.
|
||||||
static std::string FindLibrary(const char* name,
|
static std::string FindLibrary(const char* name,
|
||||||
const std::vector<std::string>& path);
|
const std::vector<std::string>& path,
|
||||||
|
const cmMakefile *makefile = 0);
|
||||||
|
|
||||||
///! return true if the file is a directory.
|
///! return true if the file is a directory.
|
||||||
static bool FileIsDirectory(const char* name);
|
static bool FileIsDirectory(const char* name);
|
||||||
|
|
Loading…
Reference in New Issue