Re: Switching GTK version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Meson is new to me, but here is what I do in my configure.ac.

The fragment below checks for various versions of GTK+ and glib and sets appropriate variables.
You can also force gtk+ 2.x by passing --disable-gtk3 as a configure flag.




HAVE_GTK_VERSION3=false

AC_ARG_ENABLE( gtk3, [  --disable-gtk3     Disable gtk+ 3.x and compile with gtk+ 2.x] , disable_gtk3=yes)

if test "x$disable_gtk3" != "xyes" ; then

echo -n "checking for GTK+ >= 3.0.0... "

PKG_CHECK_EXISTS([gtk+-3.0 >= 3.0.0],[HAVE_GTK_VERSION3=true],[HAVE_GTK_VERSION3=false])

if test "x$HAVE_GTK_VERSION3" = "xfalse"; then
echo "no"
else
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0.0)
fi

else

echo "Not checking for gtk+ 3.x"

fi

if test "x$HAVE_GTK_VERSION3" = "xfalse"; then

echo -n "checking for GTK+ >= 2.4.0... "

PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4.0)

PKG_CHECK_EXISTS([gtk+-2.0 >= 2.16.0],[HAVE_GTK_VERSION216=true],[HAVE_GTK_VERSION216=false])

PKG_CHECK_EXISTS([gtk+-2.0 >= 2.6.0],[HAVE_GTK_VERSION206=true],[HAVE_GTK_VERSION206=false])

echo "- Compiling with gtk+ 2.x -"

else
GTK3_VERSION=`$PKG_CONFIG --modversion gtk+-3.0`

echo "- Compiling with gtk+ version " $GTK3_VERSION " -"


PKG_CHECK_EXISTS([gtk+-3.0 >= 3.10.0],[HAVE_GTK_VERSION310=true],[HAVE_GTK_VERSION310=false])

PKG_CHECK_EXISTS([gtk+-3.0 >= 3.11.0],[HAVE_GTK_VERSION311=true],[HAVE_GTK_VERSION311=false])

HAVE_GTK_VERSION216=true
HAVE_GTK_VERSION206=true

if test "$HAVE_GTK_VERSION310" = "true"; then
if test "$HAVE_GTK_VERSION311" = "false"; then
GTK310_WARN=true
fi
fi


fi

AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)

PKG_CHECK_EXISTS([glib-2.0 >= 2.14.0],[HAVE_GLIB_VERSION214=true],[HAVE_GLIB_VERSION214=false])
PKG_CHECK_EXISTS([glib-2.0 >= 2.4.0],[HAVE_GLIB_VERSION24=true],[HAVE_GLIB_VERSION24=false])


Regards,
Gabriel.




On Tue, Aug 22, 2017 at 5:07 PM, Link Dupont <link@xxxxxxxxxxx> wrote:
Hi Igor,

On Tue, 2017-08-22 at 15:48 -0400, Igor Korot wrote:
>  Hi, ALL,
> I have setup to do my development for GTK+2 and GTK+3 on 2 different
> machines.
> My project is on GitHub and there is one codebase.
>
> What's the best way to set up Makefiles?

You're going to find this is a matter of opinion. Traditionally, GTK+
and GNOME projects have used GNU autotools for their build system. Many
are now moving to meson. Either way, I suggest you take some time and
learn one or both in order to make an informed decision about which
build system is best for you.

Meson is relatively new, and has most of its documentation on its
website[1]. GNU autotools has a vast online manual available[2],
however I recommend reading "Autotools: A Practition's Guide to to GNU
Autoconf, Automake, and Libtool"[3] to get a hands-on understanding of
the autotools suite.

1: http://mesonbuild.com/
2: http://www.gnu.org/software/autoconf/manual/, etc.
3: https://www.nostarch.com/autotools.htm

You could, of course, eschew all of those and use your own hand-
maintained Makefile. You'll find varying levels of opinion there too,
although you'll encounter some pretty compelling arguments against
maintaining your own hand-crafted Makefiles anywhere you look. In this
case, you could consider at least using pkg-config to find out whether
your required libraries are installed and where they are located on
your build host.

> Is it feasible to define some environment variable and select GTK
> version if it defined?
>
> Or there is a better alternative?
>
> Thank you.
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> https://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux