2006-10-01 00:02:39 +08:00
|
|
|
/*
|
|
|
|
-----BEGIN QCMOD-----
|
|
|
|
name: libboost
|
2007-04-04 05:49:52 +08:00
|
|
|
arg: with-libboost-inc=[path], Path to libboost include files
|
2010-03-30 19:35:20 +08:00
|
|
|
arg: with-libboost-lib=[path], Path to libboost library files
|
2006-10-01 00:02:39 +08:00
|
|
|
-----END QCMOD-----
|
|
|
|
*/
|
2010-04-07 17:52:43 +08:00
|
|
|
#include <boost/version.hpp>
|
2011-10-26 01:56:54 +08:00
|
|
|
#include <libtorrent/version.hpp>
|
|
|
|
|
2006-10-01 00:02:39 +08:00
|
|
|
class qc_libboost : public ConfObj
|
|
|
|
{
|
|
|
|
public:
|
2011-10-26 01:56:54 +08:00
|
|
|
qc_libboost(Conf *c) : ConfObj(c) {}
|
|
|
|
QString name() const { return "libboost"; }
|
|
|
|
QString shortname() const { return "libboost"; }
|
|
|
|
|
2010-04-07 17:35:43 +08:00
|
|
|
QString findBoostLib(QString path, QString lib) const {
|
|
|
|
QString name;
|
|
|
|
QDir libDir(path);
|
|
|
|
QStringList filters;
|
2010-04-07 17:48:04 +08:00
|
|
|
filters << "libboost_"+lib+"*-mt*.so";
|
2010-04-07 17:35:43 +08:00
|
|
|
QStringList result = libDir.entryList(filters, QDir::Files);
|
|
|
|
if(!result.empty()) {
|
|
|
|
name = result.first().mid(3);
|
|
|
|
// Remove .so
|
|
|
|
name.chop(3);
|
2010-04-10 02:45:33 +08:00
|
|
|
} else {
|
|
|
|
// Fall back to non -mt boost lib
|
|
|
|
filters.clear();
|
|
|
|
filters << "libboost_"+lib+"*.so";
|
|
|
|
result = libDir.entryList(filters, QDir::Files);
|
|
|
|
if(!result.empty()) {
|
|
|
|
name = result.first().mid(3);
|
|
|
|
// Remove .so
|
|
|
|
name.chop(3);
|
|
|
|
}
|
2010-04-07 17:35:43 +08:00
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
2011-10-26 01:56:54 +08:00
|
|
|
|
|
|
|
bool exec(){
|
|
|
|
QStringList sl;
|
|
|
|
QString s = conf->getenv("QC_WITH_LIBBOOST_INC");
|
|
|
|
if (!s.isEmpty())
|
|
|
|
sl << s;
|
|
|
|
sl << "/usr/include";
|
|
|
|
sl << "/usr/local/include";
|
|
|
|
bool found = false;
|
|
|
|
foreach (s, sl) {
|
|
|
|
if (conf->checkHeader(s, "boost/format.hpp")
|
|
|
|
#if LIBTORRENT_VERSION_MAJOR == 0 && LIBTORRENT_VERSION_MINOR < 16
|
|
|
|
&& conf->checkHeader(s, "boost/filesystem/path.hpp")
|
|
|
|
#endif
|
|
|
|
) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
conf->addIncludePath(s);
|
|
|
|
|
|
|
|
// Find library
|
|
|
|
s = conf->getenv("QC_WITH_LIBBOOST_LIB");
|
2010-04-07 17:35:43 +08:00
|
|
|
QStringList required_libs;
|
2010-04-07 17:52:43 +08:00
|
|
|
#if BOOST_VERSION >= 103500
|
2010-04-09 23:26:41 +08:00
|
|
|
required_libs << "system";
|
2010-04-07 17:52:43 +08:00
|
|
|
#endif
|
2011-10-26 01:56:54 +08:00
|
|
|
#if LIBTORRENT_VERSION_MAJOR == 0 && LIBTORRENT_VERSION_MINOR < 16
|
2011-09-23 02:42:31 +08:00
|
|
|
required_libs << "filesystem" ;
|
2011-10-26 01:56:54 +08:00
|
|
|
#endif
|
2012-02-27 03:24:32 +08:00
|
|
|
required_libs << "thread";
|
2010-04-07 17:35:43 +08:00
|
|
|
QStringList libDirs;
|
2011-10-26 01:56:54 +08:00
|
|
|
if (!s.isEmpty())
|
|
|
|
libDirs << s;
|
2010-04-07 17:35:43 +08:00
|
|
|
libDirs << "/usr/lib/" << "/usr/lib64/" << "/usr/local/lib/" << "/usr/local/lib64/";
|
2011-10-26 01:56:54 +08:00
|
|
|
|
2010-04-07 17:35:43 +08:00
|
|
|
foreach(const QString& lib, required_libs) {
|
2011-10-26 01:56:54 +08:00
|
|
|
bool found = false;
|
|
|
|
foreach(const QString& libDir, libDirs) {
|
|
|
|
QString detected_name = findBoostLib(libDir, lib);
|
|
|
|
if(!detected_name.isEmpty()) {
|
2010-04-07 17:35:43 +08:00
|
|
|
conf->addLib("-l"+detected_name);
|
2011-10-26 01:56:54 +08:00
|
|
|
found = true;
|
|
|
|
break;
|
2010-04-07 17:35:43 +08:00
|
|
|
}
|
|
|
|
}
|
2011-10-26 01:56:54 +08:00
|
|
|
if(!found) {
|
|
|
|
printf("Could not find boost %s library!\n", qPrintable(lib));
|
|
|
|
return false;
|
|
|
|
}
|
2010-04-07 17:35:43 +08:00
|
|
|
}
|
2011-10-26 01:56:54 +08:00
|
|
|
return true;
|
|
|
|
}
|
2006-10-01 00:02:39 +08:00
|
|
|
};
|