merovingian
merovingian

Reputation: 517

CMake does not produce Makefile

I'm using VS Code on windows. I have a simple CMakelists.txt like this:

cmake_minimum_required(VERSION 3.0)

project(HelloWorld)

add_executable(HelloWorld main.cpp)

When I run it, it produces a bunch of build, vcxproj, etc. But it does not create any Makefile. So when I run make I get: make: *** No targets specified and no makefile found. Stop.

Here is a screenshot

screenshot

What is wrong here?

Upvotes: 0

Views: 484

Answers (2)

user20158758
user20158758

Reputation:

I think you should generate it with cmake -G "Unix Makefiles". It seems like now you have Visual Studio as a default generator. You can check all possible generators with cmake --help.

Upvotes: 2

ahmad parvaresh
ahmad parvaresh

Reputation: 1

Use following command to build correctly:

  1. cmake -Bbuild -G "MinGW Makefiles"

this command will create a folder named build in your working directory and inside it there will be a CMakeFiles folder, cmake_install.cmake file, CMakeCache.txt file, and Makefile file.

  1. cd build

  2. use mingw32-make command instead of usual make command.

then you will have your executable file in build folder.

Upvotes: 0

Related Questions