Skip to content

Commit

Permalink
qt version selection during configure
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsiomb committed Dec 31, 2023
1 parent 1850554 commit 0d8a028
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 0d8a028

Please sign in to comment.