Skip to content

Commit

Permalink
Merge pull request #2776 from ZedThree/cmake-optional-uninstall-target
Browse files Browse the repository at this point in the history
CMake: Don't add uninstall target and CPack config if not top-level
  • Loading branch information
WardF authored Oct 27, 2023
2 parents 329c4c9 + b41b79a commit a5d15a5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
#
Expand Down Expand Up @@ -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()

0 comments on commit a5d15a5

Please sign in to comment.