Better error messages when trying to use a non-enabled language
Lets presume the following CMakeLists.txt
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
project(Test LANGUAGES CXX)
add_executable(t t.cpp v.cpp)
set_source_files_properties(v.cpp t.cpp PROPERTIES LANGUAGE C)
Error message:
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_C_COMPILE_OBJECT
This doesn't tell the user what went wrong. We should instead provide some diagnostic that the C
language needs to be enabled via enable_language
or project
in the root most CMakeLists.txt