From 92ad8e7194db3d4e715fa2a2f8d7af5af7e97503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Fri, 24 Sep 2021 23:20:42 +0200 Subject: [PATCH] Fix scope of CMake Policy variables Commit 7d47760d37b4 ("moving some settings to an apposite cmake file") moved the `cmake_policy(SET CMP0072 NEW)` from the toplevel scope to the scope of the included file. For details, see https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html Set NO_POLICY_SCOPE when including the file, to move the POLICIES back to the toplevel scope. Also remove the extra cmake_minimum_version from external/CMakeLists.txt, as it implicitly calls `cmake_policy(VERSION 3.10)`, resetting any policies introduced with cmake 3.11 and newer (i.e. CMP0072 and CMP0077). Fixes #1095. --- src/CMakeLists.txt | 2 +- src/cmake/meshlab_global_settings.cmake | 4 +++- src/external/CMakeLists.txt | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 558f6f87d8..122f0dbf39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,7 @@ option(MESHLAB_IS_NIGHTLY_VERSION "Nightly version of meshlab will be used inste ### Dependencies list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/meshlab_global_settings.cmake") +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/meshlab_global_settings.cmake" NO_POLICY_SCOPE) include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/meshlab_tools.cmake") #message(STATUS "Searching for required components") diff --git a/src/cmake/meshlab_global_settings.cmake b/src/cmake/meshlab_global_settings.cmake index d3925b157a..283645a104 100644 --- a/src/cmake/meshlab_global_settings.cmake +++ b/src/cmake/meshlab_global_settings.cmake @@ -8,7 +8,9 @@ if(POLICY CMP0072) endif() #enable setting options with SET cmake command -set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) +if(POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) +endif() ### Build settings set(CMAKE_C_STANDARD 99) diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt index 2dbe12d27e..86c3a89404 100644 --- a/src/external/CMakeLists.txt +++ b/src/external/CMakeLists.txt @@ -2,8 +2,6 @@ # Copyright 2019, 2020, Visual Computing Lab, ISTI - Italian National Research Council # SPDX-License-Identifier: BSL-1.0 -cmake_minimum_required(VERSION 3.10) - option( ALLOW_OPTIONAL_EXTERNAL_MESHLAB_LIBRARIES "Allow to use/build optional external libraries"