[CMake] Shared library from sources in several subdirectories
Bruce Stephens
bruce.r.stephens at gmail.com
Mon Dec 7 17:51:06 EST 2015
On Mon, Dec 7, 2015 at 9:08 AM, Nils Gladitz <nilsgladitz at gmail.com> wrote:
> I would avoid creating these single use, per directory libraries entirely.
>
>
Well, creating the static libraries is obviously just an artifact of our
current
build scheme, so it makes sense to ditch it.
Creating these CMake object libraries doesn't seem bad; is there some
reason to avoid doing that? A reason for doing it is it gives targets for
target_include_directories, so just the crypto objects can be built with
the OpenSSL include directory.
Also for some reason setting the POSITION_INDEPENDENT_CODE
property for the top-level shared library (the default anyway) doesn't
seem to propagate down (and maybe it can't), and the named thing
makes it easy to apply the property to the sources. Though now I look,
I could use set_property on the sources (or the directory), and I could
use set_property similarly to add include directories (and compile
definitions).
> A single target can build sources located in any number of directories.
>
> If you want to subdivide the source file listing of that one target for
> organizational purposes you can do so with e.g. include(), target_sources()
> and/or list variables.
>
Thanks for suggesting that. For some reason it hadn't occurred to me.
I'm not sure whether that would work out better for this particular case
or not, or for the larger library I'd like to do (with ~500 sources in a
tree
of ~40 directories).
(I suspect there's not that much in it ultimately and worrying about the
choice is as much bike shedding as anything.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151207/3f0a8f8d/attachment.html>
More information about the CMake
mailing list