Lucas Schneider
Lucas Schneider

Reputation: 131

CMake Compiler Identification Error

I'm having the following problem when trying to build a project using CMake:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):

I'm executing the following command: cmake . inside the CMake project folder.

The error also states that I shoulkd try to set the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER enviroment variables to the compiler paths. And so did I. I've set the variables to the following paths, respectively: C:\MinGW\bin\gcc.exe and C:\MinGW\bin\g++.exe.

The error kept happening. My CMakeLists looks like this:

cmake_minimum_required(VERSION 2.8.9)
project (hello)
add_executable(hello helloworld.cpp)

I have no CMake knowledge at all so consider that it is possible that I've forgotten some basic stuff.

What am I missing?

Upvotes: 1

Views: 1606

Answers (1)

Lucas Schneider
Lucas Schneider

Reputation: 131

I found out what I was doing wrong.

I was not choosing the correct generator, and the following fixed it:

cmake -G "MinGW Makefiles" ..

After selecting MinGW generator, everything worked just fine.

Upvotes: 2

Related Questions