From 0d8a0289a79a0f5b25a5d052e305bb37d8d933d7 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 1 Jan 2024 01:26:03 +0200 Subject: [PATCH] qt version selection during configure --- Makefile.in | 5 ++--- configure | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index f66ba22..160a6d3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,10 +17,9 @@ incpath = -I. -I$(PREFIX)/include libpath = -L$(PREFIX)/lib CFLAGS = $(warn) $(dbg) $(opt) $(incpath) -fPIC $(add_cflags) -MMD -CXXFLAGS = -std=c++11 $(warn) $(dbg) $(opt) $(incpath) -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets` \ +CXXFLAGS = $(cxxstd) $(warn) $(dbg) $(opt) $(incpath) -fPIC $(qt_cflags) \ $(add_cflags) -MMD -LDFLAGS = $(libpath) `pkg-config --libs Qt5Core Qt5Gui Qt5Widgets` -lspnav -lX11 \ - $(add_ldflags) +LDFLAGS = $(libpath) $(qt_libs) -lspnav -lX11 $(add_ldflags) $(bin): $(obj) $(CXX) -o $@ $(obj) $(LDFLAGS) diff --git a/configure b/configure index 5260d42..00897c2 100755 --- a/configure +++ b/configure @@ -38,6 +38,33 @@ for arg; do esac done + +detect_qt() +{ + qt6libs='Qt6Core Qt6Gui Qt6Widgets' + qt5libs='Qt5Core Qt5Gui Qt5Widgets' + + printf 'Detecting Qt libraries ... ' + + if pkg-config --cflags $qt6libs >/dev/null 2>&1; then + echo 'found Qt6' + qt_cflags=`pkg-config --cflags $qt6libs` + qt_libs=`pkg-config --libs $qt6libs` + cxxstd='-std=c++17' + elif pkg-config --cflags $qt5libs >/dev/null 2>&1; then + echo 'found Qt5' + qt_cflags=`pkg-config --cflags $qt5libs` + qt_libs=`pkg-config --libs $qt5libs` + cxxstd='-std=c++11' + else + echo 'failed to find Qt5 or Qt6' >&2 + exit 1 + fi +} + +detect_qt + +echo echo " prefix: $PREFIX" echo " optimize for speed: $OPT" echo " include debugging symbols: $DBG" @@ -55,6 +82,10 @@ if [ "$OPT" = 'yes' ]; then echo 'opt = -O3' >>Makefile fi +echo "qt_cflags = $qt_cflags" >>Makefile +echo "qt_libs = $qt_libs" >>Makefile +echo "cxxstd = $cxxstd" >>Makefile + if [ -n "$CFLAGS" ]; then echo "add_cflags = $CFLAGS" >>Makefile fi