CMake does not consider variables used when accessed via the $CACHE{var} syntax
Consider the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.25)
project(foo LANGUAGES)
message(STATUS "FOO=$CACHE{FOO}")
If I configure this project with -DFOO=1234
, it will output
-- FOO=1234
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
FOO
-- Build files have been written to: /tmp/cmake/build
If I change the message to "FOO=${FOO}" it does not output the warning.