Discussion:
[CMake] How to find GTK3 in CMake
Harry Mallon
2018-11-20 16:03:11 UTC
Permalink
Hi,

FindGTK and FindGTK2 exist in the CMake tree. How come there isn't one for GTK3? Should the GTK2 one work, or is there another way?

Harry


Harry Mallon
Senior Software Engineer
T+44 203 7000 989 
60 Poland Street | London | England | W1F 7NT
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman
David Demelier
2018-11-21 08:46:35 UTC
Permalink
Post by Harry Mallon
Hi,
FindGTK and FindGTK2 exist in the CMake tree. How come there isn't one for GTK3? Should the GTK2 one work, or is there another way?
GNOME people don't like CMake (they use meson). The philosophy behind
CMake is to let upstream projects provides their own CMake configuration
packages rather than providing Find modules for every single library
existing in the world.

CMake should already not provide any of these, but this general
recommendation came after.

It's the same thing for pkg-config, pkg-config by itself does not
provide any .pc file.

Also, Gtk is much more tied to Linux than being portable. I think that's
why portable software don't use Gtk that much and thus, not CMake either.

Regards,
--
David
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.o
Eric Noulard
2018-11-21 09:22:15 UTC
Permalink
Post by Harry Mallon
Post by Harry Mallon
Hi,
FindGTK and FindGTK2 exist in the CMake tree. How come there isn't one
for GTK3? Should the GTK2 one work, or is there another way?
GNOME people don't like CMake (they use meson). The philosophy behind
CMake is to let upstream projects provides their own CMake configuration
packages rather than providing Find modules for every single library
existing in the world.
Right and the fact is even traced here:
https://gitlab.kitware.com/cmake/cmake/issues/15888
Post by Harry Mallon
CMake should already not provide any of these, but this general
recommendation came after.
It's the same thing for pkg-config, pkg-config by itself does not
provide any .pc file.
Also, Gtk is much more tied to Linux than being portable. I think that's
why portable software don't use Gtk that much and thus, not CMake either.
Some project nevertheless uses GTK3 and CMake so that you may borrow
hopefully working
FindGTK3.cmake module from them:
E.g.
Darktable:
https://redmine.darktable.org/projects/darktable/repository/changes/cmake/modules/FindGTK3.cmake
WebKit:
https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGTK3.cmake

and probably many others.
--
Eric
David Demelier
2018-11-21 09:36:09 UTC
Permalink
Good. I was already considering providing a cmake file after migrating
SWI-Prolog to cmake. Are there good guidelines for this? Pkg-config asks
for providing a .pc file and installing in a well-known place. Is there
a similar place for project cmake `find' files or some other convention
to make them available to users?
Yes, it requires a little bit of boilerplate as CMake is a bit more
extensive than pkg-config.

https://cmake.org/cmake/help/v3.12/manual/cmake-packages.7.html#creating-packages

Note: lot of things are optional, this guide shows everything you can do
with provided package.

But the minimal required is:

1. install(TARGETS yourlibrary EXPORT yourlibrary-targets)
2. install(EXPORT yourlibrary-targets FILE yourlibrary-targets.cmake
NAMESPACE yourlibrary DESTINATION lib/cmake/yourlibrary)
3. install(FILES yourlibrary-config.cmake DESTINATION lib/cmake/yourlibrary)

And create yourlibrary-config.cmake with

include("${CMAKE_CURRENT_LIST_DIR}/yourlibrary-targets.cmake")

Regards
--
David
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http
Harry Mallon
2018-11-21 11:36:02 UTC
Permalink
Hi again,

Thanks David and Eric. I have actually used cmake’s pkgconfig integration to support this library. As you say (about it not being very portable) I only needed it on Linux so pkgconfig is a reasonable thing to use.

Thanks,
Harry


Harry Mallon

Senior Software Engineer

[http://codex.online/?action=asset&id=E3D62C3D-A12C-447D-87A5-F36E7C2AA9A4]<https://codex.online/>

T +44 203 7000 989<callto:+44%20203%207000%20989>

60 Poland Street | London | England | W1F 7NT

[http://admin.codex.online/?action=asset&id=132CD8A9-76B5-48B4-80D3-F5E5C57FB76E]
A Star is Born Halloween 13 Reasons Why

Loading...