[CMake] make a project also a subproject

Leif Walsh leif.walsh at gmail.com
Fri Jun 22 13:43:58 EDT 2012


That is very encouraging. I remembered getting problems but haven't tried on 2.8.8 yet I guess. Thanks, I'll try it soon. 

Sent from my iPhone

On Jun 22, 2012, at 13:32, David Cole <david.cole at kitware.com> wrote:

> 
> 
> On Fri, Jun 22, 2012 at 12:10 PM, Leif Walsh <leif.walsh at gmail.com> wrote:
> Suppose I have two projects, A and B.  A builds a shared lib that links with a static lib in B.
> 
> Sometimes, I want to build and test B by itself.  Other times I want to build A, which requires building B.
> 
> For now, I manually (or with a script) build B, then set an environment variable to say where the built static lib is, and then build A (which uses the environment variable).  This is...not superb.
> 
> If I wrote A's CMakeLists.txt to have add_subdirectory(B), it would error when it hit B's project(B).  It probably would work (with some tweaking) if I removed project(B), but then I couldn't build B by itself.
> 
> What is the error? This should work just fine. We have several project() commands in many projects (VTK, for example) and they are intended to work well that way. Each project() command maps to a generated *.sln file with the Visual Studio generators.
> 
> It is recommended to have only one project command per-CMakeLists file, but even multiple calls are supported.
> 
>  
> 
> Is there a "right way" to do this?  Is there a good, reliable way to detect that project(A) has already been called, and then (if that's the case) skip project(B)?  Will that work?
> 
> --
> Cheers,
> Leif
> 
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120622/87af40b1/attachment-0001.htm>


More information about the CMake mailing list