From 3dc3a211030898b02a8f56ae2ec885bb61a9a97f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 23 Mar 2021 20:12:31 +0200 Subject: [PATCH 35/36] Add OSX Qt6 mode support See osdn #41697 Signed-off-by: Marko Lindqvist --- Makefile.am | 1 + m4/qt6-darwin.m4 | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ m4/qt6.m4 | 5 ++- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 m4/qt6-darwin.m4 diff --git a/Makefile.am b/Makefile.am index 366cc9211b..5d858b7ab3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,6 +73,7 @@ EXTRA_DIST = autogen.sh \ m4/qt5.m4 \ m4/qt6.m4 \ m4/qt5-darwin.m4 \ + m4/qt6-darwin.m4 \ m4/qt-client.m4 \ m4/readline.m4 \ m4/sdl2-client.m4 \ diff --git a/m4/qt6-darwin.m4 b/m4/qt6-darwin.m4 new file mode 100644 index 0000000000..ff243ed04b --- /dev/null +++ b/m4/qt6-darwin.m4 @@ -0,0 +1,86 @@ +# Detect Qt6 headers and libraries and set flag variables for Mac OS X 10.10+ + +AC_DEFUN([FC_QT6_DARWIN], +[ + AC_ARG_WITH([qt6_framework_bin], + AS_HELP_STRING([--with-qt6-framework-bin], [path to binares of Qt6 framework (MacOS X, autodetected if wasn't specified)])) + + AC_CHECK_PROG([QTPATHS], [qtpaths], [qtpaths], [no]) + + if test "x$QTPATHS" != "xno" ; then + + AC_MSG_CHECKING([Qt6 framework]) + + if test "x$qt6_framework_bin" = "x" ; then + qt6_framework_bin="$($QTPATHS --binaries-dir)" + fi + qt6_path="$($QTPATHS --install-prefix)" + + if test "x$qt6_path" != "x" ; then + AC_LANG_PUSH([C++]) + FC_QT6_DARWIN_COMPILETEST([$qt6_path]) + if test "x$qt6_headers" = "xyes" ; then + FC_QT6_DARWIN_LINKTEST([$qt6_path]) + else + fc_qt6_usable=false + fi + AC_LANG_POP([C++]) + + if test "x$qt6_libs" = "xyes" ; then + MOCCMD="$qt6_framework_bin/moc" + AS_IF([test -x $MOCCMD], [fc_qt6_usable=true], [fc_qt6_usable=false]) + else + fc_qt6_usable=false + fi + fi + + if test "x$fc_qt6_usable" = "xtrue" ; then + AC_MSG_RESULT([found]) + else + AC_MSG_RESULT([not found]) + fi + fi +]) + +dnl Test if Qt6 headers are found from given path +AC_DEFUN([FC_QT6_DARWIN_COMPILETEST], +[ + CPPFADD=" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I$1/lib/QtWidgets.framework/Versions/Current/Headers -I$1/lib/QtGui.framework/Versions/Current/Headers -I$1/lib/QtCore.framework/Versions/Current/Headers -I. -I$1/mkspecs/macx-clang -F$1/lib " + + CPPFLAGS_SAVE="$CPPFLAGS" + CPPFLAGS="${CPPFLAGS}${CPPFADD}" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[int a; QApplication app(a, 0);]])], + [qt6_headers=yes + FC_QT6_CPPFLAGS="${FC_QT6_CPPFLAGS}${CPPFADD}"], + [CXXFLAGS_SAVE="${CXXFLAGS}" + CXXFLAGS="${CXXFLAGS} -fPIC" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[int a; QApplication app(a, 0);]])], + [qt6_headers=yes + FC_QT6_CPPFLAGS="${FC_QT6_CPPFLAGS}${CPPFADD}" + FC_QT6_CXXFLAGS="${FC_QT6_CXXFLAGS} -fPIC"]) + CXXFLAGS="${CXXFLAGS_SAVE}"]) + + CPPFLAGS="$CPPFLAGS_SAVE" +]) + +dnl Test Qt application linking with current flags +AC_DEFUN([FC_QT6_DARWIN_LINKTEST], +[ + LIBSADD=" -F$1/lib -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL" + + CPPFLAGS_SAVE="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $FC_QT6_CPPFLAGS" + CXXFLAGS_SAVE="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $FC_QT6_CXXFLAGS" + LIBS_SAVE="$LIBS" + LIBS="${LIBS}${LIBSADD}" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[int a; QApplication app(a, 0);]])], +[qt6_libs=yes + FC_QT6_LIBS="${FC_QT6_LIBS}${LIBSADD}"]) + LIBS="$LIBS_SAVE" + CPPFLAGS="${CPPFLAGS_SAVE}" + CXXFLAGS="${CXXFLAGS_SAVE}" +]) diff --git a/m4/qt6.m4 b/m4/qt6.m4 index 5cc074f584..eca661752f 100644 --- a/m4/qt6.m4 +++ b/m4/qt6.m4 @@ -4,7 +4,10 @@ AC_DEFUN([FC_QT6], [ if test "x$fc_qt6_usable" = "x" ; then FC_QT6_CPPFLAGS="-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00" - FC_QT6_GENERIC + case $host_os in + darwin*) FC_QT6_DARWIN;; + *) FC_QT6_GENERIC;; + esac fi ]) -- 2.30.2