[CMake] Cmake and Libltdl
Michael Hertling
mhertling at online.de
Fri Jun 18 04:40:46 EDT 2010
On 06/17/2010 11:29 AM, Carlos Lopez Gonzalez wrote:
> Hi,
> I'm new to cmake and want to port a C++ project which is now built using autotools to cmake build system.
> The project has some libraries (we call them modules) which are used in two applications. The applications uses lt_dladdsearchdir to add the path where to search the modules and then uses the lt_dlopenext and lt_dlsym to register the modules.
> When using cmake, do I need to use ltdl as well or will cmake replace the way the libraries are found and registered?
If your project's libraries are actually to be loaded dynamically at
the behest of the applications, i.e. "dlopened", you further need a
library to achieve this as it is a runtime affair and, thus, beyond
CMake's scope, so stay with libltdl or switch to the simpler libdl,
e.g., if you want to get rid of the libtool stuff. In either case,
you should build dlopened libraries with ADD_LIBRARY(...MODULE...)
in order to prevent other binaries to link against them explicitly.
If your libraries don't need to be dlopened - your question somewhat
seems to be targeted on this - you should build them as ordinary shared
libraries with ADD_LIBRARY(...SHARED...) and link other binaries against
them with TARGET_LINK_LIBRARIES(), so the runtime linker automatically
takes care to load them when the applications are launched. To ensure
they are found after being installed at a perhaps unusual location,
look at CMake's RPATH support, e.g.:
<http://www.cmake.org/Wiki/CMake_RPATH_handling>
'hope that helps.
Regards,
Michael
More information about the CMake
mailing list