Using Skia with CMake

2,017 views
Skip to first unread message

Marco

unread,
Sep 14, 2015, 3:03:23 AM9/14/15
to skia-discuss, mtk...@google.com
Hi,

I would like some advice on how to integrate Skia into a larger multi-platform project. I noticed that Skia by default uses GYP to generate the build files. Since I've been using CMake for a long time, I'm more familiar with and it is also used by a number of other libraries I might include one day into my project, I've been thinking at how to integrate Skia in a CMake-based project.

I tried generating a CMake file via GYP but couldn't get the project to compile in a Windows platform (linking errors related to libjpeg-turbo asm-generated objs - no bitness mismatch).

I heard that there might be an ongoing effort to support CMake project files and I'd be interested in it.

Suggestions are also greatly appreciated

Mike Klein

unread,
Sep 14, 2015, 9:30:46 AM9/14/15
to Marco, skia-discuss
Hi there,

I have been experimenting a bit with building Skia with CMake.  You'll find a CMakeLists.txt under skia/cmake/.  My next steps are to set up Mac and Linux continuous builds using CMake, and then to get Windows working.

While I'm sure Skia won't quite build with CMake on Windows yet (the rules are likely wrong, and the example.cpp file definitely won't build without editing), it may be worth a look anyway to get you started.

I've been tracking this effort here: https://code.google.com/p/skia/issues/detail?id=4269

Mike

cruz...@gmail.com

unread,
Sep 14, 2015, 1:41:23 PM9/14/15
to skia-discuss, marco...@gmail.com
I just wanted to say that I'm very excited to see skia build with cmake.  I've been struggling with gyp (in other projects) for long enough. :)

Mike Klein

unread,
Sep 14, 2015, 1:43:28 PM9/14/15
to skia-discuss, marco...@gmail.com
Great!  It's mail from folks like you and Marco that got me started down this road.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Marco Alesiani

unread,
Sep 14, 2015, 4:43:04 PM9/14/15
to Mike Klein, skia-discuss
Nice to hear that Mike.

I gave the CMakeLists.txt file a try on Windows. I had some problems with angle includes and defines but I managed to solve them. Now there's a lot of stuff to trim down that I suppose it shouldn't be even compiling, i.e. posix stuff (SkOSFile_posix.cpp and related).

The small changes I did are here: http://nopaste.linux-dev.org/?760926

I might continue to try and fix the file here and there when I have some time
--

__________________________

Marco Alesiani

Mike Klein

unread,
Sep 14, 2015, 6:21:43 PM9/14/15
to Marco Alesiani, skia-discuss
That's great!  This will give me a good head start with Windows!  I'll be sure to let you guys know when I've got something working, or if you beat me to it and can post up a changelist, I'd be happy to review it and get it landed.

Marco Alesiani

unread,
Sep 16, 2015, 7:36:19 AM9/16/15
to Mike Klein, skia-discuss
All right, I spent one or two hours figuring this out but I eventually got Skia building and linking with CMake and Visual Studio 2013 Win64. Angle and simd files for libjpeg proved to be the hardest part to figure out from the GYP files and to get right with CMake.

Now you just need to:

1) Checkout Skia
2) Point CMake to the CMakeLists.txt file in skia/cmake
3) Point CMake output directory wherever you want
4) Generate the project choosing Visual Studio Win64 as generator
5) Open the solution "skimake.sln" and build

It should work and build skia.dll, skia.lib for the linking and example.exe (tested - outputs a nice png with a 'Hello world' text).

I committed the CMakeLists.txt file to my github Vectis experimental branch here: 



For the developers: this is a hackish/dirty work in progress. Things to be fixed:
- only x64 is supported
- I didn't try SKIA_GDI (experimental) and directly went for the DirectWrite - this should need an option in the CMake configuration
- make sure yasm and custom build rules paths are set correctly - if the hierarchy changes CMake will just blow things up
- compilation works but there are LOTS and LOTS of warnings (over 9000), if this is okay nevermind but since most of them are related to deprecated functions either consider fixing or suppressing them
- Release mode is untested - I suppose it won't be a big deal but might need some fixing

A huge thanks to Mike and Brian for the help they're giving me on this mailing list.
--

__________________________

Marco Alesiani
Reply all
Reply to author
Forward
0 new messages