Policy CMP0126 warning when using CheckLanguage.cmake with --trace-expand
cmake_minimum_required(VERSION 3.16)
project(proj LANGUAGES)
include(CheckLanguage)
set(__lang CXX)
check_language(${__lang})
# Only happens on first configuration
cmake .. --trace-redirect=a.txt
Trace will be written to a.txt
-- Looking for a CXX compiler
-- Looking for a CXX compiler - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
CMake Warning (dev) at /Users/alex/Dev/cmake/Modules/CheckLanguage.cmake:102 (set):
Policy CMP0126 is not set: set(CACHE) does not remove a normal variable of
the same name. Run "cmake --help-policy CMP0126" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
For compatibility with older versions of CMake, normal variable
"CMAKE_CXX_COMPILER" will be removed from the current scope.
Call Stack (most recent call first):
CMakeLists.txt:8 (check_language)
This warning is for project developers. Use -Wno-dev to suppress it.
Using CMake 3.21.1.