[CMake] subprojects

Tomasz Grobelny tomasz at grobelny.oswiecenia.net
Thu Oct 27 16:19:48 EDT 2011


On Thursday 27 October 2011 18:34:33 Michael Wild wrote:
> On 10/27/2011 05:46 PM, Tomasz Grobelny wrote:
> > I have several subprojects (eg. libA and libB) and I want to make a
> > parent project that would group both of them. The problem is that libB
> > depends on
> > 
> > what is installed by libA. I have come up with two ideas:
> >  1. Configure libA and libB as ExternalProjects - the build process works
> > but when I open the parent project in Visual Studio I do not see the
> > source and header files.
> > 
> >  2. Use add_subdirectory command - this make the project look good in VS,
> > but doesn't build well as libB build is started before installing libA.
> > How do I solve this problem? Is it possible to either add source files in
> > (1) or add dependency on install of libA to libB in (2)? Or maybe some
> > other option?
> 
> The only way of getting libA installed before libB is built is indeed
> using ExternalProject.
> 
> However, in your case I would prefer to restructure libA such that it's
> build tree resembles the installation tree closely enough, such that you
> can build libB against it. E.g. if you need header files to be located
> in a specific structure which is different from that in the source tree,
> use either configure_file(... COPYONLY) commands, or if you don't want
> that, you can configure_file(...) wrapper headers with the same names
> which include the actual files through absolute paths.
> 
So the idea is to simulate install tree inside build tree. Makes sense, I'll 
try that. Thanks.
-- 
Regards,
Tomasz Grobelny


More information about the CMake mailing list