From 8caa64161eadd7139c6e3758461c8fbb98dd4475 Mon Sep 17 00:00:00 2001 From: Willem Deconinck Date: Mon, 10 Jun 2024 10:24:00 +0200 Subject: [PATCH] Add policy to detect invalid indices --- cmake/ecbuild_policies.cmake | 5 +++++ tests/ecbuild_add_option/test_project/CMakeLists.txt | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/ecbuild_policies.cmake b/cmake/ecbuild_policies.cmake index 4e835859..41f57bf1 100644 --- a/cmake/ecbuild_policies.cmake +++ b/cmake/ecbuild_policies.cmake @@ -43,4 +43,9 @@ if( POLICY CMP0074 ) cmake_policy( SET CMP0074 NEW ) endif() +# Detect invalid indices in the ``list()`` command, new in version 3.21 +if( POLICY CMP0121 ) + cmake_policy( SET CMP0121 NEW ) +endif() + endif() diff --git a/tests/ecbuild_add_option/test_project/CMakeLists.txt b/tests/ecbuild_add_option/test_project/CMakeLists.txt index 388e0c39..32e13518 100644 --- a/tests/ecbuild_add_option/test_project/CMakeLists.txt +++ b/tests/ecbuild_add_option/test_project/CMakeLists.txt @@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR) find_package( ecbuild REQUIRED ) project( test_add_option VERSION 0.1.0 LANGUAGES NONE ) -list(INSERT 0 CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - ecbuild_add_option(FEATURE TEST_A) # should default to ON ecbuild_add_option(FEATURE TEST_B DEFAULT ON) ecbuild_add_option(FEATURE TEST_C DEFAULT OFF)