[OpendTect_Developers] R: CMake Help

Kristofer Tingdahl kristofer.tingdahl at dgbes.com
Mon Jul 9 14:35:36 CEST 2012


Dear Antonio,


thanks for your e-mail. CMake is relatively easy to understand once you
know the basics. The reason we switched was primarily that we felt pmake
was not a standard, off the shelf system, and there were hence no exerience
of it among external developers.

I will seek to elaborate on some solutions below:


On Mon, Jul 9, 2012 at 12:26 PM, Corrao Antonio <Antonio.Corrao at eni.com>wrote:

> Dear all,
> I started planning for migrating my home written plugins (currently
> deployed on version 4.2) to version 4.4.
> The main difficulty I have found is related to external libraries: all my
> plugin link external libraries (either dynamic or static ones), both
> commercial and in-house developed.
>
> The Pmake system was fairly easy to grasp, and I did make all
> modifications needed to support such functionalities (the original mkshlibs
> script did not handle large libraries too well - unpacking them - but it
> was easy to customize).
>
> Now, I have no experience with cmake and it seems fairly elaborate to
> digest from scratch. Do you have any example of cmake file for a plugin
> that links external shared/static libraries?
> Also, I would appreciate some pointers to cmake tutorials/how-to(s) in
> order to have a minimal understanding of how it works (without spending too
> much time) and to be able to do small modifications.
>

To link in a static library into your plugin, simply do:

set ( OD_MODULE_STATIC_LIBS "path/to/your/static/lib.a"
"path/to/your/second/static/lib.a" )

cmake will extract the object files from these, and put them into your
plugin.

Shared external libraries are added by the

set ( OD_MODULE_EXTERNAL_LIBS "path/to/your/shared/libA.so"
"path/to/your/second/shared/libB.so" )


In general, the documentation of CMake is rather comprehensive, and should
be a good starting point for it:
http://www.cmake.org/cmake/help/v2.8.8/cmake.html

In our implementation, there is a large macro doing most of the work, and
that is sitting in CMakeModules/ODMacroUtils.cmake

The OD_INIT_MODULE() macro is called once for each module (in your case
plugin) and adds the executables and libraries to the make-system. Hence
the CMakeLists.txt in each module sets up a number of variables, and then
calls this macro. You can however work completely independent from our
system, and not use our macros.


If there are any more specific questions you have, like "How do I do X with
CMake?", let us know!


Sincerely,


Kristofer Tingdahl
-- 
Kristofer Tingdahl, Ph. D.
CEO
dGB Earth Sciences
http://www.dgbes.com <https://www.facebook.com/OpendTect>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20120709/d635d545/attachment.html>


More information about the Developers mailing list