Detect common cases of keyword<->language name confusion in project() command
Consider the error reported here: A user mis-types a keyword in their project()
command, e.g.
project(foo Version 1.0)
or perhaps:
project(foo LANG CXX)
They should get an error message making it (relatively) clear what they did wrong. Instead, what the user gets is:
CMake Error: Could not find cmake module file: CMakeDetermineVersionCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_Version_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
and so on. It is not at all obvious to the lay reader what the cause of these messages is. If you already know CMake was trying to interpret "Version" as a language name, then you go "oh, I see what's going on" - but this is unlikely to be the case for users who make this mistake in the first place.
I suggest CMake try to detect at least a few common cases of such syntax errors:
- Wrong keyword case (like Version <-> VERSION)
- Use of invalid shorthands like LANG <-> LANGUAGES
This is about mitigation, not perfect coverage, so a couple dozen invalid language names could be specifically checked for instead of applying some complex heuristic logic.
See also #23768 .