KcFnMi
KcFnMi

Reputation: 6171

cmake --build vs make, what the difference?

After

cd build
cmake -B . -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -S ..

Looks like

cmake --build .

and

make

do the same here on macOS.

So, when should I use one or the other?

Upvotes: 8

Views: 8267

Answers (3)

daparic
daparic

Reputation: 4474

make is not a recognized command in Windows. In times like this, cmake --build . is your friend.

cmake build . also works, sometimes and I don't know the deeper explanations of these phenomena.

Upvotes: 1

ixSci
ixSci

Reputation: 13708

For a simple use there is not much difference, except that cmake --build is more generic and works with any generator. So today you use make, tomorrow ninja or msbuild and CMake handles it with simple cmake --build which you can put in a script or readme.

But since the inception of presets these 2 methods started to really diverge. You can add some things in the build part of your preset which then can be invoked by cmake --build --preset MyPreset while you can't do the same with simple make.

So since you are using CMake as your project tool I'd recommend to start using its interface for the build since that's how it will be meant to use in the future anyway (at least it seems so).

Upvotes: 13

reiend
reiend

Reputation: 21

cmake -B ...typehere

type - build type e.g .sln projects for vs studio

make - build your project

cmake - allows you to create a different build types for your project.

Upvotes: -1

Related Questions