[CMake] best way to handle subdirectory libraries ?

Dan Ibanez dan.a.ibanez at gmail.com
Tue Jul 12 14:11:10 EDT 2016


Hello,

I've used CMake for a while but only recently
discovered several features for better installing a package, and am
trying to update the way I use CMake.

My question as to do with projects which contain
several modules/components/libraries, each of which is in a subdirectory.
Each library may depend on other libraries in other subdirectories.
I've set up two GitHub repos with my current understanding
of how this should be done in CMake:

https://github.com/ibaned/two_libs
https://github.com/ibaned/use_two_libs

This works, but a few things are naggingly sub-optimal, such
as the way include directories are passed from one sub-dir to another:

https://github.com/ibaned/two_libs/blob/master/add_nums/CMakeLists.txt#L8

Is there a better way to carry include dirs across scopes ?

Our real project right now generates Config.cmake files for each
subdirectory
and then other subdirectories use find_package just to get this info across:

https://github.com/SCOREC/core/blob/master/pcu/CMakeLists.txt#L44

Other projects have a whole system atop CMake that manages this.
I'm trying to get a sense of what the "best" setup looks like using pure
CMake.

Any advice about this is much appreciated,

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160712/8269e239/attachment.html>


More information about the CMake mailing list