Merge pull request #2776 from ZedThree/cmake-optional-uninstall-target

CMake: Don't add uninstall target and CPack config if not top-level
This commit is contained in:
Ward Fisher 2023-10-27 10:58:34 -06:00 committed by GitHub
commit a5d15a5857
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,9 +6,7 @@
# Set Project Properties
##################################
#Minimum required CMake Version
cmake_minimum_required(VERSION 3.12.0)
# CMake 3.12: Use libraries specified in CMAKE_REQUIRED_LIBRARIES for check include macros
#Project Name
project(netCDF
@ -18,6 +16,14 @@ DESCRIPTION "NetCDF is a set of software libraries and machine-independent data
)
set(PACKAGE "netCDF" CACHE STRING "")
# Backport of built-in `PROJECT_IS_TOP_LEVEL` from CMake 3.21
if (NOT DEFINED NETCDF_IS_TOP_LEVEL)
set(NETCDF_IS_TOP_LEVEL OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(NETCDF_IS_TOP_LEVEL ON)
endif ()
endif ()
#####
# Version Info:
#
@ -2790,5 +2796,8 @@ install(
####
# CPack inclusion must come last.
# INCLUDE(CPack)
INCLUDE(CMakeInstallation.cmake)
option(NETCDF_PACKAGE "Create netCDF-C package " ${NETCDF_IS_TOP_LEVEL})
if (NETCDF_PACKAGE)
include(CMakeInstallation.cmake)
endif()