Skip to content

Commit

Permalink
Fix scope of CMake Policy variables
Browse files Browse the repository at this point in the history
Commit 7d47760 ("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 cnr-isti-vclab#1095.
  • Loading branch information
StefanBruens committed Sep 24, 2021
1 parent 170ec29 commit 92ad8e7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion src/cmake/meshlab_global_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 92ad8e7

Please sign in to comment.