qt.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. # Build Qt
  3. set -e
  4. OPTIONS=""
  5. WINCROSS="false"
  6. for var in "$@"
  7. do
  8. if [ $var == "release" ]; then
  9. OPTIONS+="-DBUILD_SHARED_LIBS=OFF "
  10. fi
  11. if [ $var == "win-cross" ]; then
  12. WINCROSS="true"
  13. OPTIONS+="-DCMAKE_TOOLCHAIN_FILE=../../../toolchain-mingw-w64.cmake -DBUILD_qtwayland=OFF "
  14. fi
  15. done
  16. CORES=$(getconf _NPROCESSORS_ONLN)
  17. JOBS=$(($CORES-1))
  18. BASEDIR=$PWD/thirdparty/qt
  19. DEPLOYDIR=$BASEDIR/install
  20. QT_MAJOR=6
  21. QT_MINOR=1
  22. QT_BUGFIX=0
  23. UNAME_OUT="$(uname -s)"
  24. case "${UNAME_OUT}" in
  25. Linux*) MACHINE=Linux;;
  26. Darwin*) MACHINE=Mac;;
  27. CYGWIN*) MACHINE=Cygwin;;
  28. MINGW*) MACHINE=MinGw;;
  29. *) MACHINE="UNKNOWN:${UNAME_OUT}"
  30. esac
  31. if [[ ($MACHINE == "Linux") && ($WINCROSS == "false") ]]; then
  32. OPTIONS+="-DINPUT_xcb=yes "
  33. fi
  34. if [ $MACHINE == "Mac" ]; then
  35. OPTIONS+="-DBUILD_qtwayland=OFF "
  36. fi
  37. URL="https://download.qt.io/official_releases/qt/$QT_MAJOR.$QT_MINOR/$QT_MAJOR.$QT_MINOR.$QT_BUGFIX/single/qt-everywhere-src-$QT_MAJOR.$QT_MINOR.$QT_BUGFIX.tar.xz"
  38. mkdir -p "$BASEDIR"
  39. if [ -d "$DEPLOYDIR" ]; then
  40. rm -rf "$DEPLOYDIR"
  41. fi
  42. mkdir -p "$DEPLOYDIR"
  43. pushd "$BASEDIR"
  44. if [ ! -f qt-everywhere-src-$QT_MAJOR.$QT_MINOR.$QT_BUGFIX.tar.xz ]; then
  45. wget $URL
  46. fi
  47. if [ -d "qt-everywhere-src-$QT_MAJOR.$QT_MINOR.$QT_BUGFIX" ]; then
  48. rm -rf "qt-everywhere-src-$QT_MAJOR.$QT_MINOR.$QT_BUGFIX"
  49. fi
  50. tar -xf "qt-everywhere-src-$QT_MAJOR.$QT_MINOR.$QT_BUGFIX.tar.xz"
  51. pushd "qt-everywhere-src-$QT_MAJOR.$QT_MINOR.$QT_BUGFIX"
  52. cmake $OPTIONS -DBUILD_qtscxml=OFF -DBUILD_qtdatavis3d=OFF -DBUILD_qtcharts=OFF\
  53. -DBUILD_qtquickcontrols2=OFF -DBUILD_qtvirtualkeyboard=OFF -DBUILD_qtshadertools=OFF\
  54. -DBUILD_qttranslations=OFF -DBUILD_qtdoc=OFF -DBUILD_qt3d=OFF -DBUILD_qtnetworkauth=OFF\
  55. -DBUILD_qt5compat=OFF -DBUILD_qtcoap=OFF -DBUILD_qtlottie=OFF -DBUILD_qtmqtt=OFF\
  56. -DBUILD_qtopcua=OFF -DBUILD_qtquick3d=OFF -DBUILD_qtquicktimeline=OFF -DBUILD_qttools=OFF\
  57. -DBUILD_qtactiveqt=OFF -DBUILD_WITH_PCH=OFF\
  58. -DCMAKE_INSTALL_PREFIX="$DEPLOYDIR"\
  59. -DQT_BUILD_EXAMPLES=FALSE -DQT_BUILD_TESTS=FALSE\
  60. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DINPUT_optimize_size=yes -G Ninja
  61. cmake --build . --parallel $JOBS
  62. cmake --install .
  63. popd