On Wed, Feb 20, 2019 at 3:36 PM Timothy Wrona <tjwrona1...@gmail.com> wrote:

> (Included cmake-developers list as well in case this may have just been
> something that should work that was overlooked with the FetchContent module)
>
> On Tue, Feb 19, 2019 at 11:32 PM Timothy Wrona <tjwrona1...@gmail.com>
> wrote:
>
>> I am having an issue with using FetchContent to grab two subprojects that
>> both contain a "doxygen" target to build the documentation.
>>
>> Both of these subprojects need to be able to be built independently and
>> when built on their own they compile fine (along with their documentation),
>> but when I pull them into one project using "FetchContent" I get an error
>> saying I can't define the "doxygen" target more than once.
>>
>> I imagine this kind of issue would come up all of the time when using a
>> "superbuild" pattern. Is there a typical way of handling this?
>>
>
I thought this limitation was already mentioned in the FetchContent docs,
but it seems it isn't. If two different dependencies define the same global
target name, then they cannot be combined into the same build via
add_subdirectory(). CMake doesn't allow a target to be redefined (although
it does allow additional commands to be added to an existing custom
target). I'll try to add some docs to FetchContent to mention this
limitation, but they will not make it into the 3.14 release - the
limitation has always been there right from when FetchContent was first
introduced in 3.11.

A traditional superbuild that uses ExternalProject won't have a problem
with this because a subproject's own targets are not combined with targets
of other subprojects into a single build. Instead, the top level project
only sees the targets that ExternalProject itself creates. This is most
likely the best workaround if you are not able to modify the target names
used in the subprojects you want to combine.

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

Get the hand-book for every CMake user: Professional CMake: A Practical
Guide <https://crascit.com/professional-cmake/>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers

Reply via email to