[CMake] How to handle a submodule existing twice in a project?

Andreas Pakulat apaku at gmx.de
Thu May 17 19:01:00 EDT 2012


Hi,

On Thu, May 17, 2012 at 11:36 PM, David Doria <daviddoria at gmail.com> wrote:

> Why are you doing that? If TestB is always available as sub-dir under
>> TestA it doesn't make much sense to also add it as a subdirectory of the
>> parent of TestA - IMHO. Test/CMakeLists.txt can still use all targets from
>> TestB, since target names are always valid across the complete project.
>>
>> Since TestA is a submodule, it should always be present in the sources
>> anyway.
>>
>> Andreas
>>
>
> I use functionality of TestB in Test. If TestA decides to remove TestB,
> then Test will break. I was trying to "hide" the implementation of TestA
> by requiring both TestA and TestB to be submodules of Test, regardless of
> whether or not TestA has TestB as a submodule of its own.
>
> See what I mean?
>

Yeah. Well, in that case I'd simply check for the TestB target thats
defined in TestB/CMakeLists.txt as condition for the top-levels
add_subdirectory:

if(NOT TARGET TestB)
  add_subdirectory(TestB)
endif()

That should work.

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120518/4e88ab22/attachment-0001.htm>


More information about the CMake mailing list