2006-09-30 20:02:39 +04:00
|
|
|
/*
|
|
|
|
-----BEGIN QCMOD-----
|
|
|
|
name: libboost
|
2007-04-04 01:49:52 +04:00
|
|
|
arg: with-libboost-inc=[path], Path to libboost include files
|
2010-03-30 15:35:20 +04:00
|
|
|
arg: with-libboost-lib=[path], Path to libboost library files
|
2006-09-30 20:02:39 +04:00
|
|
|
-----END QCMOD-----
|
|
|
|
*/
|
2010-04-07 13:52:43 +04:00
|
|
|
#include <boost/version.hpp>
|
2006-09-30 20:02:39 +04:00
|
|
|
class qc_libboost : public ConfObj
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
qc_libboost(Conf *c) : ConfObj(c) {}
|
|
|
|
QString name() const { return "libboost"; }
|
|
|
|
QString shortname() const { return "libboost"; }
|
2010-04-07 13:35:43 +04:00
|
|
|
QString findBoostLib(QString path, QString lib) const {
|
|
|
|
QString name;
|
|
|
|
QDir libDir(path);
|
|
|
|
QStringList filters;
|
2010-04-07 13:48:04 +04:00
|
|
|
filters << "libboost_"+lib+"*-mt*.so";
|
2010-04-07 13:35:43 +04:00
|
|
|
QStringList result = libDir.entryList(filters, QDir::Files);
|
|
|
|
if(!result.empty()) {
|
|
|
|
name = result.first().mid(3);
|
|
|
|
// Remove .so
|
|
|
|
name.chop(3);
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
2006-09-30 20:02:39 +04:00
|
|
|
bool exec(){
|
2007-04-04 01:49:52 +04:00
|
|
|
QString s;
|
|
|
|
s = conf->getenv("QC_WITH_LIBBOOST_INC");
|
|
|
|
if(!s.isEmpty()) {
|
|
|
|
if(!conf->checkHeader(s, "boost/format.hpp")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!conf->checkHeader(s, "boost/date_time/posix_time/posix_time.hpp")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!conf->checkHeader(s, "boost/filesystem/path.hpp")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!conf->checkHeader(s, "boost/thread.hpp")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
QStringList sl;
|
|
|
|
sl << "/usr/include";
|
|
|
|
sl << "/usr/local/include";
|
|
|
|
bool found = false;
|
|
|
|
foreach(s, sl){
|
|
|
|
if(conf->checkHeader(s, "boost/format.hpp")){
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!conf->checkHeader(s, "boost/date_time/posix_time/posix_time.hpp")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!conf->checkHeader(s, "boost/filesystem/path.hpp")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!conf->checkHeader(s, "boost/thread.hpp")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
conf->addIncludePath(s);
|
2010-03-30 15:35:20 +04:00
|
|
|
// Find library
|
|
|
|
s = conf->getenv("QC_WITH_LIBBOOST_LIB");
|
2010-04-07 13:35:43 +04:00
|
|
|
QStringList required_libs;
|
2010-04-07 13:52:43 +04:00
|
|
|
required_libs
|
|
|
|
#if BOOST_VERSION >= 103500
|
|
|
|
<< "system"
|
|
|
|
#endif
|
|
|
|
<< "filesystem" << "thread";
|
2010-04-07 13:35:43 +04:00
|
|
|
QStringList libDirs;
|
|
|
|
libDirs << "/usr/lib/" << "/usr/lib64/" << "/usr/local/lib/" << "/usr/local/lib64/";
|
|
|
|
foreach(const QString& lib, required_libs) {
|
|
|
|
if(!s.isEmpty()) {
|
|
|
|
QString detected_name = findBoostLib(s, lib);
|
|
|
|
if(detected_name.isEmpty()) {
|
|
|
|
printf("Could not find boost %s library!\n", qPrintable(lib));
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
conf->addLib("-l"+detected_name);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bool found = false;
|
|
|
|
foreach(const QString& libDir, libDirs) {
|
|
|
|
QString detected_name = findBoostLib(libDir, lib);
|
|
|
|
if(!detected_name.isEmpty()) {
|
|
|
|
conf->addLib("-l"+detected_name);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found) {
|
|
|
|
printf("Could not find boost %s library!\n", qPrintable(lib));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-04 01:49:52 +04:00
|
|
|
return true;
|
2006-09-30 20:02:39 +04:00
|
|
|
}
|
|
|
|
};
|