cmake: set policy CMP0174 when it exists

Avoid warning about empty string arguments to functions config_option()
and config_string() in newer cmake versions.

Both behaviour versions (with and without policy) are safe for how we
are using those arguments. Setting the policy when it exists removes the
warning.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
This commit is contained in:
Gerwin Klein 2026-06-12 12:08:00 +10:00
parent d82b2049a7
commit c377a3233a

View file

@ -6,6 +6,13 @@
cmake_minimum_required(VERSION 3.16.0)
# Set policy for potentially empty single arguments when that policy is supported. Both behaviours
# (with and without policy) are safe for our uses. If no policy is set, we get a warning for
# function config_option below when it is called with empty strings.
if(POLICY CMP0174)
cmake_policy(SET CMP0174 NEW)
endif()
# Wrapper function around find_file that generates a fatal error if it isn't found
# Is equivalent to find_file except that it adds CMAKE_CURRENT_SOURCE_DIR as a path and sets
# CMAKE_FIND_ROOT_PATH_BOTH