From 1c757cce34344dfecc9a724034680225143f92b7 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 22 Mar 2017 15:42:35 +0200 Subject: [PATCH] [build] Autodetect Qt{4,5} --- .travis.yml | 2 +- Makefile | 20 ++++++++++++-------- platform/qt/bitrise-qt4.yml | 1 - scripts/check-qt.sh | 9 +++++++++ 4 files changed, 22 insertions(+), 10 deletions(-) create mode 100755 scripts/check-qt.sh diff --git a/.travis.yml b/.travis.yml index 256e6a2aa..cc7f71549 100644 --- a/.travis.yml +++ b/.travis.yml @@ -166,7 +166,7 @@ matrix: dist: trusty language: cpp compiler: "qt4-gcc5-release" - env: BUILDTYPE=Release _CXX=g++-5 _CC=gcc-5 WITH_QT_4=1 + env: BUILDTYPE=Release _CXX=g++-5 _CC=gcc-5 addons: *qt4 before_script: - mapbox_start_xvfb diff --git a/Makefile b/Makefile index 0edfe685a..2eb2728b8 100644 --- a/Makefile +++ b/Makefile @@ -361,20 +361,23 @@ endif #### Qt targets ##################################################### -ifeq ($(WITH_QT_4), 1) -QT_ROOT_PATH = build/qt4-$(BUILD_PLATFORM)-$(BUILD_PLATFORM_VERSION) -else -QT_ROOT_PATH = build/qt-$(BUILD_PLATFORM)-$(BUILD_PLATFORM_VERSION) -endif - -ifneq (,$(shell which qmake)) -export QT_INSTALL_DOCS = $(shell qmake -query QT_INSTALL_DOCS) +QT_QMAKE_FOUND := $(shell command -v qmake 2> /dev/null) +ifdef QT_QMAKE_FOUND + export QT_INSTALL_DOCS = $(shell qmake -query QT_INSTALL_DOCS) + ifeq ($(shell qmake -query QT_VERSION | head -c1), 4) + QT_ROOT_PATH = build/qt4-$(BUILD_PLATFORM)-$(BUILD_PLATFORM_VERSION) + WITH_QT_4=1 + else + QT_ROOT_PATH = build/qt-$(BUILD_PLATFORM)-$(BUILD_PLATFORM_VERSION) + WITH_QT_4=0 + endif endif export QT_OUTPUT_PATH = $(QT_ROOT_PATH)/$(BUILDTYPE) QT_BUILD = $(QT_OUTPUT_PATH)/build.ninja $(QT_BUILD): $(BUILD_DEPS) + @scripts/check-qt.sh mkdir -p $(QT_OUTPUT_PATH) (cd $(QT_OUTPUT_PATH) && cmake -G Ninja ../../.. \ -DCMAKE_BUILD_TYPE=$(BUILDTYPE) \ @@ -392,6 +395,7 @@ ifeq ($(HOST_PLATFORM), macos) MACOS_QT_PROJ_PATH = $(QT_ROOT_PATH)/xcode/mbgl.xcodeproj $(MACOS_QT_PROJ_PATH): $(BUILD_DEPS) + @scripts/check-qt.sh mkdir -p $(QT_ROOT_PATH)/xcode (cd $(QT_ROOT_PATH)/xcode && cmake -G Xcode ../../.. \ -DMBGL_PLATFORM=qt \ diff --git a/platform/qt/bitrise-qt4.yml b/platform/qt/bitrise-qt4.yml index 0a08d684f..d8c7e0788 100644 --- a/platform/qt/bitrise-qt4.yml +++ b/platform/qt/bitrise-qt4.yml @@ -19,7 +19,6 @@ workflows: brew link qt brew linkapps qt export BUILDTYPE=Debug - export WITH_QT_4=1 make qt-app make run-qt-test - is_debug: 'yes' diff --git a/scripts/check-qt.sh b/scripts/check-qt.sh new file mode 100755 index 000000000..578003824 --- /dev/null +++ b/scripts/check-qt.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +if [ ! $(command -v qmake 2> /dev/null) ]; then + echo "No qmake found - missing Qt development files" + exit 1 +fi