1 # Detect Qt5 headers and libraries and set flag variables for Mac OS X 10.10+
3 AC_DEFUN([FC_QT5_DARWIN],
5 AC_ARG_WITH([qt5_framework_bin],
6 AS_HELP_STRING([--with-qt5-framework-bin], [path to binares of Qt5 framework (MacOS X, autodetected if wasn't specified)]))
8 AC_CHECK_PROG([QTPATHS], [qtpaths], [qtpaths], [no])
10 if test "x$QTPATHS" != "xno" ; then
12 AC_MSG_CHECKING([Qt5 framework])
14 if test "x$qt5_framework_bin" = "x" ; then
15 qt5_framework_bin="$($QTPATHS --binaries-dir)"
17 qt5_path="$($QTPATHS --install-prefix)"
19 if test "x$qt5_path" != "x" ; then
21 FC_QT5_DARWIN_COMPILETEST([$qt5_path])
22 if test "x$qt5_headers" = "xyes" ; then
23 FC_QT5_DARWIN_LINKTEST([$qt5_path])
29 if test "x$qt5_libs" = "xyes" ; then
30 MOCCMD="$qt5_framework_bin/moc"
31 AS_IF([test -x $MOCCMD], [fc_qt5_usable=true], [fc_qt5_usable=false])
37 if test "x$fc_qt5_usable" = "xtrue" ; then
38 AC_MSG_RESULT([found])
40 AC_MSG_RESULT([not found])
45 dnl Test if Qt5 headers are found from given path
46 AC_DEFUN([FC_QT5_DARWIN_COMPILETEST],
48 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 "
50 CPPFLAGS_SAVE="$CPPFLAGS"
51 CPPFLAGS="${CPPFLAGS}${CPPFADD}"
52 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
53 [[int a; QApplication app(a, 0);]])],
55 FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"],
56 [CXXFLAGS_SAVE="${CXXFLAGS}"
57 CXXFLAGS="${CXXFLAGS} -fPIC"
58 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
59 [[int a; QApplication app(a, 0);]])],
61 FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"
62 FC_QT5_CXXFLAGS="${FC_QT5_CXXFLAGS} -fPIC"])
63 CXXFLAGS="${CXXFLAGS_SAVE}"])
65 CPPFLAGS="$CPPFLAGS_SAVE"
68 dnl Test Qt application linking with current flags
69 AC_DEFUN([FC_QT5_DARWIN_LINKTEST],
71 LIBSADD=" -F$1/lib -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL"
73 CPPFLAGS_SAVE="$CPPFLAGS"
74 CPPFLAGS="$CPPFLAGS $FC_QT5_CPPFLAGS"
75 CXXFLAGS_SAVE="$CXXFLAGS"
76 CXXFLAGS="$CXXFLAGS $FC_QT5_CXXFLAGS"
78 LIBS="${LIBS}${LIBSADD}"
79 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
80 [[int a; QApplication app(a, 0);]])],
82 FC_QT5_LIBS="${FC_QT5_LIBS}${LIBSADD}"])
84 CPPFLAGS="${CPPFLAGS_SAVE}"
85 CXXFLAGS="${CXXFLAGS_SAVE}"