I understand that to compile and install something from source, in a Unix System, the three steps involved are:
1) ./configure
2) make
3) make install
When I checked the installation of OpenCV from source, I noticed that it had no ./configure
step, but it had a cmake
step. This gave me the idea that cmake
was equivalent of ./configure
. I also read that cmake
can generate build systems such as Makefiles
, which is what the ./configure
step does.
However, this article (See first paragraph of what is the difference?
) says that cmake
performs the actual build as well. If that is the case, why does OpenCV installation instruct for make
after cmake
? Also, I often see that cmake
is compared to make
, not ./configure
. So, where does cmake
actually fit in?
Make (or rather a Makefile) is a buildsystem - it drives the compiler and other build tools to build your code. CMake is a generator of buildsystems. It can produce Makefiles, it can produce Ninja build files, it can produce KDEvelop or Xcode projects, it can produce Visual Studio solutions.
Description. The “cmake” executable is the CMake command-line interface. It may be used to configure projects in scripts. Project configuration settings may be specified on the command line with the -D option. CMake is a cross-platform build system generator.
CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform. The CMake Tools extension integrates Visual Studio Code and CMake to make it easy to configure, build, and debug your C++ project.
Running CMake from the command line From the command line, cmake can be run as an interactive question and answer session or as a non-interactive program. To run in interactive mode, just pass the option “-i” to cmake. This will cause cmake to ask you to enter a value for each value in the cache file for the project.
Yes, cmake
is like a configure step of autotools. It does not perform a build itself, but just generates necessary files for building (Makefiles, Visual Studio projects, etc.).
CMake has --build
option, but this option just invokes underlying build system, so you can't use CMake as standalone build tool. This is different from plain Makefiles, because you can write them manually and then make
them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With