CMake fails to build simplest possible example

Apologies in advance for how simple this is, very new to CMake and can’t get the simplest possible example working.

I’ve got a project consisting of a single .c file (main.c), the contents of which are:

#include <stdio.h>

int main() {
    return 0;
}

In the same directory I’ve got a CMakeLists.txt file:

cmake_minimum_required(VERSION 3.10)
project(Test VERSION 1.0
                    DESCRIPTION "CMake Test"
                    LANGUAGES c)
add_executable(Test main.c)

Running cmake ./ in this directory results in:

CMake Error: Could not find cmake module file: CMakeDeterminecCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_c_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_c_COMPILER
CMake Error: Could not find cmake module file: /home/j/projects/poc/cmaketut/CMakeFiles/3.20.5/CMakecCompiler.cmake
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_c_COMPILER could be found.

  Tell CMake where to find the compiler by setting the CMake cache entry
  CMAKE_c_COMPILER to the full path to the compiler, or to the compiler name
  if it is in the PATH.


CMake Error: Could not find cmake module file: CMakecInformation.cmake
CMake Error: CMAKE_c_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Looking in CMakeCache.txt I see: CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc

and an ls -la /usr/bin/cc reveals that it is there:

lrwxrwxrwx 1 root root 43 Dec 12 13:47 /usr/bin/cc -> /usr/x86_64-pc-linux-gnu/gcc-bin/11.2.0/gcc

At this point I’m not really sure what I’ve done wrong.

Your LANGUAGES setting is wrong. It is called C (with an uppercase C). But you don’t need to give the project command a LANGUAGES argument at all, as C and CXX are defaults.

I knew it’d be something silly on my end, thanks, that got it working.