cmake -B parameter

If I have a project sample

../sample/
├── build
├── CMakeLists.txt
├── main.cpp
└── release

Is the two command the same thing?

cd sample\build
cmake -S ..\ 
cd sample
cmake -S .\ -B build

ref:
cmake --install

They look equivalent to me.

-S stands for CMAKE_SOURCE_DIR

-B stands for CMAKE_BINARY_DIR

If you don’t specify -S / -B they are implied to be your current working directory.

So yes the 2 commands shown are equivalent

The only thing that comes to mind for me is that -B will create the build directory for you if it doesn’t exist.

In fact, the two commands will generate different size file or additional file.
Is it reasonable?

I’m not sure what you are referring to.

Here is the sample https://github.com/fmtlib/fmt

Sure, but what, exactly, are you referring to by:

method1

cd sample\build
cmake -S ..\ 
cmake --build xxx
cmake --install xxx

method1 result
image

method2

cd sample
cmake -S .\ -B build
cmake --build xxx
cmake --install xxx

method2 result
image

Are the two methods same for install it?

1 Like

OK, so the vcxproj files look to be different sizes (though at this resolution, there could be small diffs in many of these files). But are they different in any material way?

1 Like

It looks like testing wasn’t enabled for method 1. It is missing some of the files that we see with method 2 (e.g. RUN_TESTS.vcxproj* and CTestTestfile.cmake). I have no explanation, just making an observation.

That feels like one had ENABLE_TESTING=ON (or OFF. That could certainly increase the file sizes as well.

ENABLE_TESTING=ON no use with command.

Thanks for your help.