From 016eb7591c8f529b2f58a267b47b6ea2534d5e76 Mon Sep 17 00:00:00 2001 From: Bradley Lowekamp Date: Tue, 26 Nov 2024 12:59:09 -0500 Subject: [PATCH] Use cmake_minimum_required to set min and policy_max CMake version >3.30 produce a deprecated awarning when only, a min argument less that 3.10 is pass to cmake_minimum_required. Using the additional policy_max version range specified the max policy setting at the same time. --- CMakeLists.txt | 13 +++---------- Examples/CMakeLists.txt | 2 +- Utilities/gdcmcharls/CMakeLists.txt | 10 +--------- Utilities/gdcmexpat/CMakeLists.txt | 2 +- Utilities/gdcmjpeg/CMakeLists.txt | 10 +--------- Utilities/gdcmmd5/CMakeLists.txt | 2 +- Utilities/gdcmopenjpeg/CMakeLists.txt | 18 +----------------- Utilities/gdcmuuid/CMakeLists.txt | 2 +- Utilities/gdcmzlib/CMakeLists.txt | 2 +- Utilities/getopt/CMakeLists.txt | 2 +- Utilities/socketxx/CMakeLists.txt | 12 +----------- 11 files changed, 13 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 758a60e68d..9cfca7f989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,7 @@ -cmake_minimum_required(VERSION 3.9.2 FATAL_ERROR) +set(GDCM_MAX_VALIDATED_CMAKE_VERSION "3.13.4") -set(GDCM_MAX_VALIDATED_CMAKE_VERSION "3.13.1") -if("${CMAKE_VERSION}" VERSION_LESS_EQUAL "${GDCM_MAX_VALIDATED_CMAKE_VERSION}") - # As of 2018-12-04 GDCM has been validated to build with cmake version 3.13.1 new policies. - # Set and use the newest cmake policies that are validated to work - set(GDCM_CMAKE_POLICY_VERSION "${CMAKE_VERSION}") -else() - set(GDCM_CMAKE_POLICY_VERSION "${GDCM_MAX_VALIDATED_CMAKE_VERSION}") -endif() -cmake_policy(VERSION ${GDCM_CMAKE_POLICY_VERSION}) +# Set minimum required version of CMake, and policy version +cmake_minimum_required(VERSION 3.9.2...${GDCM_MAX_VALIDATED_CMAKE_VERSION} FATAL_ERROR) # travis-ci wants 3.9.2 # GDCM version 3.0.0 will only support C++11 and greater if(CMAKE_CXX_STANDARD EQUAL "98" ) diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index ca76e1badf..2960ce3b92 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.7...3.13.4) # Choose behavior based on whether we are building inside the GDCM tree. if(GDCM_BINARY_DIR) diff --git a/Utilities/gdcmcharls/CMakeLists.txt b/Utilities/gdcmcharls/CMakeLists.txt index 69f093c047..faf39c611a 100644 --- a/Utilities/gdcmcharls/CMakeLists.txt +++ b/Utilities/gdcmcharls/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT CHARLS_NAMESPACE) @@ -11,14 +11,6 @@ string(TOLOWER ${CHARLS_NAMESPACE} CHARLS_LIBRARY_NAME) project(${CHARLS_NAMESPACE} CXX) -foreach(p - CMP0042 - CMP0063 - ) - if(POLICY ${p}) - cmake_policy(SET ${p} NEW) - endif() -endforeach() #----------------------------------------------------------------------------- # CHARLS version number diff --git a/Utilities/gdcmexpat/CMakeLists.txt b/Utilities/gdcmexpat/CMakeLists.txt index b654d86446..7e158d4ecf 100644 --- a/Utilities/gdcmexpat/CMakeLists.txt +++ b/Utilities/gdcmexpat/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT EXPAT_NAMESPACE) diff --git a/Utilities/gdcmjpeg/CMakeLists.txt b/Utilities/gdcmjpeg/CMakeLists.txt index d1649f3c6c..023f9ce306 100644 --- a/Utilities/gdcmjpeg/CMakeLists.txt +++ b/Utilities/gdcmjpeg/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT JPEG_NAMESPACE) @@ -17,14 +17,6 @@ string(TOLOWER ${JPEG_NAMESPACE} JPEG_LIBRARY_NAME) project(${JPEG_NAMESPACE} C) -foreach(p - CMP0042 - CMP0063 - ) - if(POLICY ${p}) - cmake_policy(SET ${p} NEW) - endif() -endforeach() # Do full dependency headers. include_regular_expression("^.*$") diff --git a/Utilities/gdcmmd5/CMakeLists.txt b/Utilities/gdcmmd5/CMakeLists.txt index 176887694d..8bbef0f428 100644 --- a/Utilities/gdcmmd5/CMakeLists.txt +++ b/Utilities/gdcmmd5/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT MD5_NAMESPACE) diff --git a/Utilities/gdcmopenjpeg/CMakeLists.txt b/Utilities/gdcmopenjpeg/CMakeLists.txt index 3bc88545e6..cd8eecddb2 100644 --- a/Utilities/gdcmopenjpeg/CMakeLists.txt +++ b/Utilities/gdcmopenjpeg/CMakeLists.txt @@ -8,23 +8,7 @@ # e.g.: # set(OPENJPEG_NAMESPACE "GDCMOPENJPEG") if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.2) -endif() - -if(COMMAND CMAKE_POLICY) - cmake_policy(SET CMP0003 NEW) - if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0)) - cmake_policy(SET CMP0042 NEW) - endif() - - foreach(p - CMP0042 - CMP0063 - ) - if(POLICY ${p}) - cmake_policy(SET ${p} NEW) - endif() - endforeach() + cmake_minimum_required(VERSION 2.8.2...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT OPENJPEG_NAMESPACE) diff --git a/Utilities/gdcmuuid/CMakeLists.txt b/Utilities/gdcmuuid/CMakeLists.txt index cd3083bf65..b7427c76fe 100644 --- a/Utilities/gdcmuuid/CMakeLists.txt +++ b/Utilities/gdcmuuid/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT UUID_NAMESPACE) diff --git a/Utilities/gdcmzlib/CMakeLists.txt b/Utilities/gdcmzlib/CMakeLists.txt index 834c4ac8f3..fc88616cb6 100644 --- a/Utilities/gdcmzlib/CMakeLists.txt +++ b/Utilities/gdcmzlib/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT ZLIB_NAMESPACE) diff --git a/Utilities/getopt/CMakeLists.txt b/Utilities/getopt/CMakeLists.txt index 4b303d04b5..a510d39e6d 100644 --- a/Utilities/getopt/CMakeLists.txt +++ b/Utilities/getopt/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() if(NOT GETOPT_NAMESPACE) diff --git a/Utilities/socketxx/CMakeLists.txt b/Utilities/socketxx/CMakeLists.txt index ce15b8aa4a..10fd29483a 100644 --- a/Utilities/socketxx/CMakeLists.txt +++ b/Utilities/socketxx/CMakeLists.txt @@ -1,17 +1,7 @@ if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 2.8.7) + cmake_minimum_required(VERSION 2.8.7...${GDCM_MAX_VALIDATED_CMAKE_VERSION}) endif() -foreach(p - CMP0022 - CMP0042 - CMP0063 # CMake 3.3.2 - ) - if(POLICY ${p}) - cmake_policy(SET ${p} NEW) - endif() -endforeach() - # http://www.linuxhacker.at/socketxx if(NOT SOCKETXX_NAMESPACE) set(SOCKETXX_NAMESPACE "SOCKETXX")