Qt + boost build integration
Sometimes it is good to be able to include boost library without need to compile the whole package beforehand - just by including simple .pri file like this:
# Wed Aug 24 09:21:20 CEST 2016
INCLUDEPATH += $$PWD/.
SOURCES +=
"$$PWD/libs/regex/src/c_regex_traits.cpp"
"$$PWD/libs/regex/src/cpp_regex_traits.cpp"
"$$PWD/libs/regex/src/cregex.cpp"
"$$PWD/libs/regex/src/fileiter.cpp"
"$$PWD/libs/regex/src/icu.cpp"
"$$PWD/libs/regex/src/instances.cpp"
"$$PWD/libs/regex/src/posix_api.cpp"
win32:SOURCES +=
unix:SOURCES +=
LIBS += -lz -lbz2
Here is a simple script that generates boost-mpi.pri script and set of headers and sources from Boost library located at /Volumes/USBSTORE/(Dev)/boost_1_61_0 path:
#!/bin/bash
OUT=.
PRI=boost-mpi.pri
/opt/local/bin/bcp \
--boost=/Volumes/USBSTORE/(Dev)/boost_1_61_0 \
boost/mpi.hpp \
boost/compute.hpp \
$OUT/
#
# build Qt include file:
#
echo "#" `date` > $PRI
echo "INCLUDEPATH += $$PWD/$OUT" >> $PRI
# exclude files that donot compile:
# shared_ptr_helper.cpp
files=""
dedups() {
eval local ff=$$1
local F=`basename $ff | sed 's/(.*)..*/1/'`
case "$files" in
*";$F"* )
local DIR=`dirname "$ff"`
local EXTENSION=${f##*.}
local fn="$DIR/$RANDOM-`basename "$ff"`"
echo "duplicate: $ff -> $fn"
mv "$ff" "$fn"
ff="$fn"
;;
* )
files="$files;$F"
;;
esac
eval $1="$ff"
}
if [ -e $OUT/libs ]; then
echo "SOURCES += " >> $PRI
for f in `find $OUT/libs -iname "*.cpp" ! -iname "shared_ptr_helper.cpp"
-path "*/src/*" ! -path "*/test/*" ! -path "*/win32/*" ! -path "*/pthread/*" | xargs`; do
dedups f
echo " "$$PWD/$f" " >> $PRI
done
echo "" >> $PRI
echo "win32:SOURCES += " >> $PRI
for f in `find $OUT/libs -iname "*.cpp" ! -iname "shared_ptr_helper.cpp"
-path "*/src/*" ! -path "*/test/*" -path "*/win32/*" | xargs`; do
dedups f
echo " "$$PWD/$f" " >> $PRI
done
echo "" >> $PRI
echo "unix:SOURCES += " >> $PRI
for f in `find $OUT/libs -iname "*.cpp" ! -iname "shared_ptr_helper.cpp"
-path "*/src/*" ! -path "*/test/*" -path "*/pthread/*" | xargs`; do
dedups f
echo " "$$PWD/$f" " >> $PRI
done
echo "" >> $PRI
echo "LIBS += -lz -lbz2" >> $PRI
fi
wc -l $PRI
PS. Sometime it is necessary to add boost/system/error_code.cpp file to the bap’s list of files to resolve some linking issues.
Comments