[CMake] actually using cmake alternative to convenience libraries

Mark Stijnman mark.stijnman at gmail.com
Fri Nov 20 09:18:49 EST 2015


On Thu, Nov 19, 2015 at 11:04 PM, Tamás Kenéz <tamas.kenez at gmail.com> wrote:

> > set(foobarSRCS foo.c bar.c)
> > set(foobarLIBS ${externalLibFound})
> >
> > which is what the FAQ entry seems to suggest. However, this variable is
> not visible to goo.c. Okay, so as an alternative, I can do this:
> >
> > set(foobarSRCS foo.c bar.c PARENT_SCOPE), etc.
>
> In similar cases I create CACHE variables:
>
>     set(foobarSRCS foo.c bar.c CACHE INTERNAL "" FORCE)
>     set(foobarLIBS ${externalLibFound} CACHE INTERNAL "" FORCE)
>
> You can also write a set_cache() macro.
>
> Tamas
>

I'd prefer using the PARENT_SCOPE option here, which will make the
variables available in the parent CMakeLists.txt.
    set(foobarSRCS foo.c bar.c PARENT_SCOPE)
    set(foobarLIBS ${externalLibFound} PARENT_SCOPE)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151120/e628cee7/attachment.html>


More information about the CMake mailing list