'How do I remove duplicate cmake targets created by sub-cmake targets?

I have a cmake project that depends on several other cmake projects. The cmake project that I am writing depends on 2 cmake projects that both create uninstall targets. These duplicate targets cause errors:

add_custom_target cannot create target "uninstall" because another target
  with the same name already exists.  The existing target is a custom target
  created in source directory

I do not need the uninstall target from either sub-cmake project. How do I exclude all targets with the name uninstall so that I don't get these errors? What other options are there available to solve this error? I am looking for a solution that is OS agnostic.



Solution 1:[1]

I sugguest you read the following documentation for Kitware : https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake . The process is quite well explained.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GPB