CMake-QA

In respond of Note:Pybind11 build from source,

So at first I went here. I get to know:

1
2
3
4
5
Usage

cmake [options] path-to-source
cmake [options] path-to-existing-build
cmake [options] -S path-to-source -B path-to-build

From the video, the mkdir seems to be what most people do. The reason to why mkdir I supposed is that it helps organize our files, so that files won’t be a mess. It helps, but not a necessity. In order to better confirm my words, I did a little experiment on it:

1
2
cmake -DCMAKE_INSTALL_PREFIX=/ .
sudo make install

It works as well. So I think the reason to mkdir is that it helps sort our files in an organized way.

While building pybind, there are files being generated, including Makefile; no additional CMakeLists.txt are generated accordingly. I’m not sure whether it is possible that cmake would generate an additional CMakeLists.txt. If it does, the reason to mkdir will be even obvious, i.e, overwritting will increase the difficulty if we want to undo.

It designated the directory of installation (link).
On my pc, while cmake -DCMAKE_INSTALL_PREFIX=/ .,

1
2
3
4
5
6
7
8
9
...
-- Installing: /usr/include/pybind11/common.h
-- Installing: /usr/include/pybind11/pybind11.h
...
while cmake -DCMAKE_INSTALL_PREFIX=/usr/local .,
...
-- Installing: /usr/local/include/pybind11/common.h
-- Installing: /usr/local/include/pybind11/pybind11.h
...