[CMake] Linking archives in a sibling directory
Raymond Wan
r.wan at aist.go.jp
Mon Dec 13 01:59:02 EST 2010
Hi Michael,
Thank you for the follow-up and sorry for my late response! I
appreciate your suggestions as they basically summarize the problems
I've been having...
On Wed, Dec 8, 2010 at 21:25, Michael Hertling <mhertling at online.de> wrote:
> Yes, absolutely, with such relations among executables and libraries,
> their source directories should be siblings instead of descendants, and
> the libraries' testing executables can be conveniently integrated using
> ADD_TEST() without interfering with the main executables. However, when
> your project grows and, hence, the number of source directories in the
> project's root increases, say 10+, you should consider to organize them
> further, e.g. like
For example, I've reached around 10 source directories when I posted
my first message to the mailing list a couple of weeks back. I
probably should have thought how to organize everything when I first
started -- but at least I'm thinking about it now instead of "much"
later!
> or whichever organizational criteria apply best, so the root directory
> doesn't fill with countless source directories. Apart from that, there
> is no need to have the top-level CMakeLists.txt create the main{1,2,3}
> executables by itself; just add a CMakeLists.txt file in each of their
> source directories as you do for the libraries, and use
>
> ADD_SUBDIRECTORY(main1)
> ADD_SUBDIRECTORY(main2)
> ADD_SUBDIRECTORY(main3)
>
> at the top level to enable them. In this way, you've a CMakeLists.txt
> file in each of your project's source directories which does exactly
> what needs to be done there, and the whole project is covered by the
> top-level CMakeLists.txt with minimal assumptions w.r.t. the source
> directories.
I see. That makes sense to me; thank you!
> IMO, there is no reason to configure with lower-level CMakeLists.txt
> files at first and switch to a top-level CMakeLists.txt later. Instead,
> start right away with one CMakeLists.txt file per source directory and
> one top-level CMakeLists.txt, and whenever a new source directory with
> its own CMakeLists.txt is added to your project, just add an according
> ADD_SUBDIRECTORY() at the top level, too. So, you will always have a
> clean and regular configurational setup without the need to bother
> with different starting points for configuring your project.
Ok -- thank you for this; I'll definitely take your advice!
Thank you for your suggestions; I realize my question wasn't directly
related to CMake syntax and more generally to how to use CMake
properly for a project of this size. Thank you for taking the time to
explain it to me; hopefully it has benefited others as well!
Ray
More information about the CMake
mailing list