[CMake] target_sources and multiple subdirs

Craig Scott craig.scott at crascit.com
Wed Jun 20 18:05:29 EDT 2018


On Thu, Jun 21, 2018 at 2:47 AM, Michael Jackson <
mike.jackson at bluequartz.net> wrote:

> I have a project where we have a bunch of plugins that are compiled. We
> are currently wrapping with Pybind11 to access those libraries from Python.
> The issue on windows is that we get a multiple DLL load error and our
> thought was to create 1 enormous python module library (Not sure if this is
> the right idea or not….)
>
>
>
> So my question has to do with how to add files to a target that might
> initially get created about 3 subdirs down from the top level
> CMakeLists.txt file but each time cmake runs through a CMake file that
> would configure a plugin can we just keep adding files to the python module
> target through the use of target_sources() command. Not sure how that works
> or if that idea would work.
>
>
>
> Thoughts or pointers would be very much welcome.
>
>
>
You should be able to use target_sources() to do that, although I'd
recommend you create the target higher up rather than burying it deeper
down in the subdirs. It would seem more logical to create the target at the
point above where all the subdirs that add sources are. Maybe have a read
of the following article for a more detailed discussion of using
target_sources() in this way:

https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/

-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180621/e9fa2f58/attachment.html>


More information about the CMake mailing list