I have a main project (called Test) that has two submodules, TestA and TestB. TestA also has a submodule, which is exactly the same TestB.<div><br><div>So there is a directory Test/TestB as well as Test/TestA/TestB</div><div>
<br></div><div>In TestA/CMakeLists.txt, I have add_subdirectory(TestB).<br clear="all">In Test/CMakeLists.txt, I have add_subdirectory(TestA) as well as add_subdirectory(TestB).</div><div><br></div><div>CMake complains that it cannot create TestB because another target with the same name already exists (which it does). What is the right way to handle this? I always assume that TestB is identical in both places (which might not be a great assumption...), so I guess I just want, in both places, to say "include TestB if it already hasn't been included." I tried to do that by replacing the add_subdirectory(TestB) calls with:</div>
<div><br></div><div><div>if(NOT TestB_SOURCE_DIR)</div><div> add_subdirectory(TestB)</div><div>endif()</div></div><div><br></div><div>but then the linker complains that it can't find TestB.</div><div><br></div><div>I have uploaded a demo project here:</div>
<div><a href="http://homepages.rpi.edu/~doriad/Upload/TestCMake2.tar.gz">http://homepages.rpi.edu/~doriad/Upload/TestCMake2.tar.gz</a></div><div><br></div><div>Thanks!</div><div><br></div><div>David<br>
</div></div>