[CMake] RE : add_subdirectory and build directory

Pierre-Julien Villoud PVilloud at movea.com
Sun Sep 13 15:59:20 EDT 2009


Thank you very much fo all your answers.. It is much clearer now... I was actually trying to use add_subdirectory to manage my dependencies but it is obviously not the best way to do it. 
Well the question is still here though, how can I "build B standalone" and build "B within A" as a dependency (well check if B is up to date before building A ?)

Thanks again

Pierre-Julien
________________________________________
De : cmake-bounces at cmake.org [cmake-bounces at cmake.org] de la part de David Cole [david.cole at kitware.com]
Date d'envoi : samedi 12 septembre 2009 12:51
À : Michael Wild
Cc : cmake; Bill Hoffman
Objet : Re: [CMake] add_subdirectory and build directory

On Sat, Sep 12, 2009 at 2:45 AM, Michael Wild <themiwi at gmail.com<mailto:themiwi at gmail.com>> wrote

True, but then you wouldn't point it at a binary directory. AFAIK, if you point project A at an out-of-source source, say project B, that project B will be built completely within the binary tree of A.


The second argument to add_subdirectory allows you to put the binary tree of "project B's build tree within project A" anywhere you want...

Of course, it should not be the same as a build tree of "standalone project B".... Because that's a different build.

Perhaps that's where the confusion is in this case?

Pierre-Julien, is that what you are expecting? When you use add_subdirectory, you should typically leave off the 2nd argument unless you just want to organize things differently than CMake does by default. But if you do use it, make sure that the directory you give it is unique across all other projects that you build. "B built within A" is different than "standalone B" -- do not try to mix and match builds with add_subdirectory -- use it as a convenient way of building a project as a component of another project...

Does that help?

Hope so,
David



More information about the CMake mailing list