Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Don't add uninstall target and CPack config if not top-level #2776

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

ZedThree
Copy link
Contributor

@ZedThree ZedThree commented Oct 23, 2023

Fixes #2597

CMake 3.21 was released in 2021 and is available in the latest release of all the big distros (see https://pkgs.org/search/?q=cmake). If it's necessary to support older versions of CMake, a reasonable backport is something like:

if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
  include(CMakeInstallation.cmake)
endif()

CMAKE_PROJECT_NAME is the top-level project name
PROJECT_NAME is the current project name (i.e. netCDF!)

It might also be friendlier to expose an option to allow changing this:

if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
  set(_default_install_option ON)
else()
  set(_default_install_option OFF)
endif()

option(INSTALL_NETCDF "Install netCDF-C" ${_default_install_option})

if (INSTALL_NETCDF)
  include(CMakeInstallation.cmake)
endif()

@WardF
Copy link
Member

WardF commented Oct 24, 2023

Thanks! Re-running CI to get an idea of what didn't work, and hopefully see that it will clear itself up.

@ZedThree
Copy link
Contributor Author

Oh, looks like the Windows build only has Cmake 3.16, so maybe it is best to use the backwards compatible version

@WardF WardF merged commit a5d15a5 into Unidata:main Oct 27, 2023
99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMake uninstall target conflicts with other previously registered uninstall targets
2 participants