2.6.5. CLI: MakeΒΆ

Usually to build an executable with Make, you need to find the directory with the Makefile and run make in it:

> cd _builds
[cgold-example/_builds]> make
Scanning dependencies of target foo
[ 50%] Building CXX object CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX executable foo
[100%] Built target foo

But CMake offers a cross-tool way to do exactly the same by cmake --build _builds:

[cgold-example]> cmake --build _builds
Scanning dependencies of target foo
[ 50%] Building CXX object CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX executable foo
[100%] Built target foo

Run foo:

[cgold-example]> ./_builds/foo
Hello from CGold!

Done!