-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·60 lines (49 loc) · 1.74 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
case "$(uname)" in
Darwin)
SED_EXT_RE_OPT=-E
;;
Linux)
SED_EXT_RE_OPT=-r
;;
*)
echo "Unrecognized platform \"$(uname)\"!"
exit 1
;;
esac
function find_all_qmake5()
{
# Returns as soon as it successfully finds a matching qmake executable.
for qmakeName in qmake-qt5 qmake-5.1 qmake; do
qmakePath="$(which $qmakeName 2>/dev/null)"
if [ $? -eq 0 ]; then
# Check Qt version
"$qmakePath" -version | sed $SED_EXT_RE_OPT 's@^Using Qt version (5\.[0-9]+\.[0-9]+) in .*@\1:'"$qmakePath"'@p;d'
fi
done
# Check paths relative to the current directory. (if you built Qt 5 from source in a similar directory to this one)
for qmakePath in "$(dirname $0)/../qt5/qtbase/bin/qmake" "$(dirname $0)/../../other/qt5/qtbase/bin/qmake"; do
if [ -x "$qmakePath" ]; then
# Check Qt version
"$qmakePath" -version | sed $SED_EXT_RE_OPT 's@^Using Qt version (5\.[0-9]+\.[0-9]+) in .*@\1:'"$qmakePath"'@p;d'
fi
done
}
if [ -z "$QMAKE" ]; then
# Find all Qt 5.x versions of qmake, sort by Qt version (descending), and print the corresponding path.
QMAKE=$(find_all_qmake5 | sort -nrt . -k 1,1 -k 2,2 -k 3,3 | head -n 1 | cut -d ':' -f 2)
fi
if [ ! -x "$QMAKE" ]; then
echo -e "\033[1;31mA valid, executable 'qmake' was not found! (QMAKE=$QMAKE)\033[m"
exit 1
fi
echo -e "\033[1;32mUsing 'qmake' at $QMAKE\033[m"
QT_INSTALL_BINS="$($QMAKE -query | awk -F : '$1 == "QT_INSTALL_BINS" {print $2}')"
QT_INSTALL_LIBS="$($QMAKE -query | awk -F : '$1 == "QT_INSTALL_LIBS" {print $2}')"
export PATH="$QT_INSTALL_BINS:$PATH"
export LD_LIBRARY_PATH="$QT_INSTALL_LIBS:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="$QT_INSTALL_LIBS/pkgconfig:$PKG_CONFIG_PATH"
mkdir -p build
cd build
cmake .. -DCMAKE_MODULE_PATH:PATH="$QT_INSTALL_LIBS/cmake" "$@"
make -j 8