[CMake] Link something to future installed library

Rolf Eike Beer eike at sf-mail.de
Sun Mar 10 12:14:01 EDT 2013


David Demelier wrote:
> Hello,
> 
> I'm trying to make a common core library that will help creating modules, my
> modules will link against it but this will not work as these modules will
> link against the library in the binary build directory.
> 
> My CMakeLists.txt is quite complexe with a lot of subdirectories so I will
> just reduce to a small example that explain my problem :
> 
> # My common library
> file(GLOB COMMON "core/*")

GLOB will generate a list of all files that match the globbing expressions and 
store it into the variable. Globbing expressions are similar to regular 
expressions, but much simpler. If RELATIVE flag is specified for an 
expression, the results will be returned as a relative path to the given path. 
(We do not recommend using GLOB to collect a list of source files from your 
source tree. If no CMakeLists.txt file changes when a source is added or 
removed then the generated build system cannot know when to ask CMake to 
regenerate.)

> add_library(core SHARED ${COMMON})
> install(TARGETS core DESTINATION "myapp/lib")
> 
> # Now create some modules
> add_library(mod1 MODULE mod.cpp)
> install(TARGETS mod1 DESTIONATION "myapp/lib/modules")
> 
> And then I would like mod1 to be linked to the future installed core
> library.
> 
> I really want my common library to be a shared library, then everyone that
> would like to create new modules can do it independently of this project.
> 
> Is there any workaround or possibilities to solve my issue?

When you install the modules, they will be linked against the install 
location. As long as they are in the build tree they will use the build tree 
location. So I guess there is no issue.

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130310/4a45180f/attachment.pgp>


More information about the CMake mailing list