[CMake] Targets organisation of complex project
Mateusz Loskot
mateusz at loskot.net
Mon Oct 12 17:06:19 EDT 2009
Philip Lowman wrote:
> On Sun, Oct 11, 2009 at 9:01 PM, Tyler Roscoe <tyler at cryptio.net> wrote:
>
>> On Sun, Oct 11, 2009 at 08:41:27PM +0100, Mateusz Loskot wrote:
>>> The sources are organised in large number of subdirectories and
>>> sort of logical sub-libraries, but the binary output of compilation
>>> is a single library.
>> [snip]
>>> It looks like the best portable approach is to walk through the whole
>>> tree of project, collect all .c and .cpp files (assigning list of files
>>> to global variables) and, back in the main CMakeLists.txt, stream all
>>> source files to single ADD_LIBRARY call.
>> This is what I would do. IME, CMake works best when you do the simplest
>> thing that can possibly work.
>>
>
> I would do what makes sense in terms of the end user. If those separate
> subdirectories are meant to be separate libraries, then build separate
> libraries. If the source code is scattered across multiple subdirectories
> but is all supposed to be part of the same library then build it together.
The case here is the latter one. Single library is the only reasonable
output of the build of our project.
> You can use PARENT_SCOPE to hand lists of source files up a directory, if
> that is of interest.
> set(FOO_SRCS ${list_of_sources} PARENT_SCOPE)
Thanks for the hint. I'll learn more about this.
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
More information about the CMake
mailing list