Skip to content

Commit

Permalink
CMake: Add backport of PROJECT_IS_TOP_LEVEL for CMake <3.21
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree committed Oct 25, 2023
1 parent 523c648 commit b41b79a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Set Project Properties
##################################

cmake_minimum_required(VERSION 3.21.0)
cmake_minimum_required(VERSION 3.12.0)

#Project Name
project(netCDF
Expand All @@ -16,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 @@ -2787,6 +2795,8 @@ install(
####

# CPack inclusion must come last.
if (PROJECT_IS_TOP_LEVEL)
option(NETCDF_PACKAGE "Create netCDF-C package " ${NETCDF_IS_TOP_LEVEL})

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

0 comments on commit b41b79a

Please sign in to comment.