C++ Qt应用程序的CI:使用不同的Qt版本生成

C++ Qt应用程序的CI:使用不同的Qt版本生成,c++,qt,continuous-integration,travis-ci,C++,Qt,Continuous Integration,Travis Ci,我使用Travis CI持续集成我的简单Qt应用程序。My.travis.yml文件如下所示(基于): 此配置允许我使用Ubuntu中的默认Qt库(Qt4.8.1和Qt5.0.2)构建我的应用程序(并运行测试) 有没有办法用其他Qt版本(4.7.x、4.8.x、5.1.x等)构建应用程序?通过添加贝内里的ppa,您可以找到更多的Qt版本。 例如,可以添加5.4版: before_install: - sudo add-apt-repository ppa:beineri/opt-qt541

我使用Travis CI持续集成我的简单Qt应用程序。My.travis.yml文件如下所示(基于):

此配置允许我使用Ubuntu中的默认Qt库(Qt4.8.1和Qt5.0.2)构建我的应用程序(并运行测试)


有没有办法用其他Qt版本(4.7.x、4.8.x、5.1.x等)构建应用程序?

通过添加贝内里的ppa,您可以找到更多的Qt版本。 例如,可以添加5.4版:

before_install:
  - sudo add-apt-repository ppa:beineri/opt-qt541 -y
install:
  - sudo apt-get install qt54base qt54websockets
script:
  - source /opt/qt54/bin/qt54-env.sh
受到答案的启发,非常感谢

使用这个.travis.yml,您将获得10个单独的构建作业-矩阵部分中的元素数。每个构建作业将安装指定的Qt版本,并将其用于Ubuntu中Qt4.8-5.7的应用程序构建,以及OS X中Qt5.5和5.7(或最新版本)的应用程序构建

如果要为Windows构建应用程序,可以尝试CI服务。配置示例(Qt 5.3-5.7):


我在我的项目中使用这些配置-。查看更新和构建日志。

Beineri也支持Qt5.5;只需在需要时替换qt55即可!那么OS X呢?
sudo添加apt存储库ppa:beineri/$BEINEREPO-y
before_install:
  - sudo add-apt-repository ppa:beineri/opt-qt541 -y
install:
  - sudo apt-get install qt54base qt54websockets
script:
  - source /opt/qt54/bin/qt54-env.sh
language: cpp

matrix:
 include:
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=48
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=51
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=52
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=53
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=54
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=55
  - os: osx
    compiler: clang
    env:
     - QT_BASE=55
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=56
  - os: linux
    dist: trusty
    sudo: required
    compiler: gcc
    env:
     - QT_BASE=57
  - os: osx
    compiler: clang
    env:
     - QT_BASE=57

before_install:
  - if [ "$QT_BASE" = "48" ]; then sudo add-apt-repository ppa:beineri/opt-qt487-trusty -y; fi
  - if [ "$QT_BASE" = "51" ]; then sudo add-apt-repository ppa:beineri/opt-qt511-trusty -y; fi
  - if [ "$QT_BASE" = "52" ]; then sudo add-apt-repository ppa:beineri/opt-qt521-trusty -y; fi
  - if [ "$QT_BASE" = "53" ]; then sudo add-apt-repository ppa:beineri/opt-qt532-trusty -y; fi
  - if [ "$QT_BASE" = "54" ]; then sudo add-apt-repository ppa:beineri/opt-qt542-trusty -y; fi
  - if [[ "$QT_BASE" = "55" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo add-apt-repository ppa:beineri/opt-qt551-trusty -y; fi
  - if [ "$QT_BASE" = "56" ]; then sudo add-apt-repository ppa:beineri/opt-qt562-trusty -y; fi
  - if [[ "$QT_BASE" = "57" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo add-apt-repository ppa:beineri/opt-qt571-trusty -y; fi
  - if [ "$TRAVIS_OS_NAME" = "linux" ]; then 
      sudo apt-get update -qq;
    else
      brew update;
    fi

install:
  - if [ "$QT_BASE" = "48" ]; then sudo apt-get install -qq opt-qt4-qmake opt-qt4-dev-tools; source /opt/qt-4.8/bin/qt-4.8-env.sh; fi
  - if [ "$QT_BASE" = "51" ]; then sudo apt-get install -qq qt51base; source /opt/qt51/bin/qt51-env.sh; fi
  - if [ "$QT_BASE" = "52" ]; then sudo apt-get install -qq qt52base; source /opt/qt52/bin/qt52-env.sh; fi
  - if [ "$QT_BASE" = "53" ]; then sudo apt-get install -qq qt53base; source /opt/qt53/bin/qt53-env.sh; fi
  - if [ "$QT_BASE" = "54" ]; then sudo apt-get install -qq qt54base; source /opt/qt54/bin/qt54-env.sh; fi
  - if [ "$QT_BASE" = "55" ]; then
      if [ "$TRAVIS_OS_NAME" = "linux" ]; then 
        sudo apt-get install -qq qt55base; source /opt/qt55/bin/qt55-env.sh; 
      else
        brew install qt55;
        brew link --force qt55;
      fi
    fi
  - if [ "$QT_BASE" = "56" ]; then sudo apt-get install -qq qt56base; source /opt/qt56/bin/qt56-env.sh; fi
  - if [ "$QT_BASE" = "57" ]; then
      if [ "$TRAVIS_OS_NAME" = "linux" ]; then 
        sudo apt-get install -qq qt57base; source /opt/qt57/bin/qt57-env.sh; 
      else
        brew install qt5;
        brew link --force qt5;
      fi
    fi

script:
  - qmake -v
  - qmake -r
  - make

notifications:
  email: false
version: '{build}'

init:
- git config --global core.autocrlf input

environment:
  matrix:
  - QT5: C:\Qt\5.3\mingw482_32
    MINGW: C:\Qt\Tools\mingw482_32
  - QT5: C:\Qt\5.4\mingw491_32
    MINGW: C:\Qt\Tools\mingw491_32
  - QT5: C:\Qt\5.5\mingw492_32
    MINGW: C:\Qt\Tools\mingw492_32
  - QT5: C:\Qt\5.6\mingw49_32
    MINGW: C:\Qt\Tools\mingw492_32
  - QT5: C:\Qt\5.7\mingw53_32
    MINGW: C:\Qt\Tools\mingw530_32

matrix:
  fast_finish: true

before_build:
- set PATH=%MINGW%\bin;%QT5%\bin;%PATH%

build_script:
- qmake -v
- qmake -r
- mingw32-make