[CMake] From autotools to cmake for existing project

Clifford Yapp cliffyapp at gmail.com
Mon Jan 17 02:51:42 EST 2011


(whoops, meant to CC the list)

On Tue, Jan 11, 2011 at 7:40 AM, Carlos Lopez Gonzalez
<carloslopezgonzalez at yahoo.es> wrote:

> So the question is:
> which is the best strategy to allow synfig to use cmake? I know that it might be
> a very complex question but I want to know which are the major roadblocks I
> would find. Anybody has previous experience with something similar? Can you
> point to me to any similar case of study?

I"m going through the autotools->CMake process now with BRL-CAD.
Major things specific to an autotools->CMake conversion:

1.  Tests you use that are suppled by Autotools.  This is a biggie -
all those HAVE_* flags in the code need the same tests, which usually
will need to be re-implemented in CMake.  Look around before doing it
yourself, sometimes people have solved similar problems.  CMake has
the tools to do this but (so far) does not have a specific library of
autotools-compatible tests (if you find one let me know)
2.  Sorting out how to manage compile flags for various profiles and
platforms - a lot of sorting, categorizing, platform testing here -
I'm not even close to done with this aspect of it.  Autotools does a
lot of automatic stuff, so you will probably find yourself "looking
behind the curtain" to see what is going on.
3.  Test on lots of platforms and configs - make sure autotools wasn't
papering over platform issues automatically and you never noticed.
Can think of at least one case where that happened.
4.  This is maybe not autotools specific, but if you have key
operations in your build that require the presence of sh, sed, m4,
etc. (a natural development when you're assuming autotools is there)
remember that they aren't available out of the box on Windows -
sometimes CMake can be used to achieve what is needed and that will be
more portable if you're looking to compile with something like Visual
Studio.

You have one big advantage - you have working build logic already.  If
your project has any significant complexity, remember to study what
DOES work when you're trying to figure out why CMake doesn't.

> I forecast the problem of replace pkconfig tools. Should I use pkconfig inside
> cmake or use the .cmake replacements to find the libraries and forget completely
> pkconfig?

Are you talking about finding 3rd party libraries?  There are some
utilities in CMake for taking advantage of pkgconfig I believe,
although I haven't ended up looking into that (so far).

> In the middle of porting, when ETL would be installed, would the
> unported synfig-core and synfig-studio parts (already with autotools) find
> properly the ETL libraries? How to proceed in that case?

If you're doing a unified build of the whole source, you should be
able to add the target name of the ETL library file to
target_link_libraries commands for the others, if I understand
properly what you are asking.  BRL-CAD builds many individual
libraries in its source that are used by other libraries, and it
hasn't been a problem.

> Please be patience with me because I'm just start learning. I have the Mastering
> cmake book and have done a whole read once, so I can understand technical
> terminology (or at last can search for it), but I don't have any experience with
> cmake and my experience with autotools is ... well better don't remind me ;)

So far I've found the plplot library to be a good resource for
practical CMake hints - you might check what they do if you hit a
particular problem.

Cheers, and best of luck - so far for me the pain of conversion looks
to be worth the effort, so hopefully you will find the same.
CY


More information about the CMake mailing list