Author: cazfi
Date: Sun May 17 23:05:10 2015
New Revision: 29106

URL: http://svn.gna.org/viewcvs/freeciv?rev=29106&view=rev
Log:
Made configure checks and options for Qt suitable for MacOS X.

Reported by David Lowe <doctorjlowe>
Patch by Alexey Novikov <alekswn>

See bug #18200

Added:
    branches/S2_5/m4/qt5-darwin.m4
Modified:
    branches/S2_5/Makefile.am
    branches/S2_5/m4/qt5.m4

Modified: branches/S2_5/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/Makefile.am?rev=29106&r1=29105&r2=29106&view=diff
==============================================================================
--- branches/S2_5/Makefile.am   (original)
+++ branches/S2_5/Makefile.am   Sun May 17 23:05:10 2015
@@ -89,6 +89,7 @@
                m4/postgres.m4                  \
                m4/progtest.m4                  \
                m4/qt5.m4                       \
+               m4/qt5-darwin.m4                \
                m4/qt-client.m4                 \
                m4/readline.m4                  \
                m4/sdl-client.m4                \

Added: branches/S2_5/m4/qt5-darwin.m4
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/m4/qt5-darwin.m4?rev=29106&view=auto
==============================================================================
--- branches/S2_5/m4/qt5-darwin.m4      (added)
+++ branches/S2_5/m4/qt5-darwin.m4      Sun May 17 23:05:10 2015
@@ -0,0 +1,84 @@
+# Detect Qt5 headers and libraries and set flag variables for Mac OS X 10.10+
+
+AC_DEFUN([FC_QT5_DARWIN],
+[
+
+  AC_MSG_CHECKING([Qt5 framework])
+
+  AC_ARG_WITH([qt5_framework_bin],
+    AS_HELP_STRING([--with-qt5-framework-bin], [path to binares of Qt5 
framework (MacOS X, autodetected if wasn't specified)]))
+  
+  if test "x$qt5_framework_bin" = "x" ; then
+    qt5_framework_bin="$(qtpaths --binaries-dir)"
+  fi
+  qt5_path="$(qtpaths --install-prefix)"
+
+  if test "x$qt5_path" != "x" ; then
+    AC_LANG_PUSH([C++])
+    FC_QT5_DARWIN_COMPILETEST([$qt5_path])
+    if test "x$qt5_headers" = "xyes" ; then
+      FC_QT5_DARWIN_LINKTEST([$qt5_path])
+    else
+      fc_qt5_usable=false
+    fi
+    AC_LANG_POP([C++])
+
+    if test "x$qt5_libs" = "xyes" ; then
+      MOCCMD="$qt5_framework_bin/moc"
+      AS_IF([test -x $MOCCMD], [fc_qt5_usable=true], [fc_qt5_usable=false])
+    else
+      fc_qt5_usable=false
+    fi
+  fi
+  
+  if test "x$fc_qt5_usable" = "xtrue" ; then
+    AC_MSG_RESULT([found])
+  else
+    AC_MSG_RESULT([not found])
+  fi
+  
+])
+
+dnl Test if Qt headers are found from given path
+AC_DEFUN([FC_QT5_DARWIN_COMPILETEST],
+[
+  CPPFADD=" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB 
-I$1/lib/QtWidgets.framework/Versions/5/Headers 
-I$1/lib/QtGui.framework/Versions/5/Headers 
-I$1/lib/QtCore.framework/Versions/5/Headers -I. -I$1/mkspecs/macx-clang 
-F$1/lib "
+
+  CPPFLAGS_SAVE="$CPPFLAGS"
+  CPPFLAGS="${CPPFLAGS}${CPPFADD}"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
+[[int a; QApplication app(a, 0);]])],
+    [qt5_headers=yes
+     FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"],
+    [CXXFLAGS_SAVE="${CXXFLAGS}"
+     CXXFLAGS="${CXXFLAGS} -fPIC"
+     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
+[[int a; QApplication app(a, 0);]])],
+      [qt5_headers=yes
+       FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"
+       FC_QT5_CXXFLAGS="${FC_QT5_CXXFLAGS} -fPIC"])
+     CXXFLAGS="${CXXFLAGS_SAVE}"])
+
+  CPPFLAGS="$CPPFLAGS_SAVE"
+])
+
+dnl Test Qt application linking with current flags
+AC_DEFUN([FC_QT5_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_QT5_CPPFLAGS"
+  CXXFLAGS_SAVE="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS $FC_QT5_CXXFLAGS"
+  LIBS_SAVE="$LIBS"
+  LIBS="${LIBS}${LIBSADD}"
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
+[[int a; QApplication app(a, 0);]])],
+[qt5_libs=yes
+ FC_QT5_LIBS="${FC_QT5_LIBS}${LIBSADD}"])
+ LIBS="$LIBS_SAVE"
+ CPPFLAGS="${CPPFLAGS_SAVE}"
+ CXXFLAGS="${CXXFLAGS_SAVE}"
+])
+

Modified: branches/S2_5/m4/qt5.m4
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/m4/qt5.m4?rev=29106&r1=29105&r2=29106&view=diff
==============================================================================
--- branches/S2_5/m4/qt5.m4     (original)
+++ branches/S2_5/m4/qt5.m4     Sun May 17 23:05:10 2015
@@ -1,6 +1,19 @@
 # Detect Qt5 headers and libraries and set flag variables
 
+AC_ARG_VAR([MOCCMD], [QT 5 moc command (autodetected it if not set)])
+
 AC_DEFUN([FC_QT5],
+[
+  if test "x$fc_qt5_usable" = "x" ; then
+    case $host_os in 
+    darwin*) FC_QT5_DARWIN;;
+    *) FC_QT5_GENERIC;;
+    esac
+  fi
+])
+ 
+
+AC_DEFUN([FC_QT5_GENERIC],
 [
   AC_LANG_PUSH([C++])
 
@@ -127,7 +140,6 @@
 AC_DEFUN([FC_QT5_TRY_MOC],
   [FC_QT5_IF_QT5_MOC([$1], [MOCCMD="$1"], [$2])])
 
-AC_ARG_VAR([MOCCMD], [QT 5 moc command (autodetected it if not set)])
 
 dnl If a usable moc command is found do $1 else do $2
 AC_DEFUN([FC_QT5_VALIDATE_MOC], [


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to