Reputation: 517
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
What is wrong here?
Upvotes: 0
Views: 484
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
Reputation: 1
Use following command to build correctly:
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.
cd build
use mingw32-make
command instead of usual make
command.
then you will have your executable file in build
folder.
Upvotes: 0