Unidata / netcdf-cxx4

Official GitHub repository for netCDF-C++ libraries and utilities.
Other
126 stars 49 forks source link

CMake uninstall target conflicts with other previously registered uninstall targets #128

Open bear24rw opened 1 year ago

bear24rw commented 1 year ago

I am trying to build netcdf-c & netcdf-cxx4 within a cmake project via FetchContent. Both netcdf-c and netcdf-cxx4 register an uninstall which violates CMP0002 and causes cmake to fail with this error:

CMake Error at build/_deps/netcdf-cxx4-src/CMakeInstallation.cmake:109 (ADD_CUSTOM_TARGET):
  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
  "build/_deps/netcdf-c-src".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  build/_deps/netcdf-cxx4-src/CMakeLists.txt:688 (INCLUDE)

Other projects have solved this issue by wrapping the custom target in an option() so that users can disable the target.

This is the same issue as https://github.com/Unidata/netcdf-c/issues/2597