skr
skr

Reputation: 944

Is calling CMake the equivalent of ./configure step?

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?

Upvotes: 5

Views: 1704

Answers (3)

zaufi
zaufi

Reputation: 7119

And as an addendum to the winner answer:

CMake also could be used as pkg-config to search for installed CMake enabled-packages ;-) Check the docs about this mode.

CMake also support CLI mode and is capable to process filesystem operations in a cross-platform way, so could be considered as a "tiny/trivial cross-platform scripting tool" ;-) -- I'm pretty happy w/ this mode, cuz I don't need to learn Windows cmd.exe commands to make file/directory copy/move/rename/&etc and my "scripts" work well in Linux and Windows...

There is also possible to use it in server mode, but this feature dedicated mostly for IDEs to integrate proper support for CMake files editing.

Comparing w/ autotools, which out-of-the-box supports only plain archives (tarballs), CMake (+CPack) could do various package formats as a build result. I used it for RPM/DEB/MSI/EXE and with a little help for NuGet packages creation.

Upvotes: 1

usr1234567
usr1234567

Reputation: 23294

The article you mentioned compars CMake and Make, which is confusing. I wound distinguish build tools, like Make or msbuild, and build generators or meta-build tools, that generate files for the build tools, like CMake or Autotools. Boths tools can be amalgamated into one as it is done by Waf.

You are right that a classical configure script has the same function as a CMake call: It will search for third-party libraries, set up the build system and prepare a config header.

Beside GNU projects, CMake gained quite some momentum. KDE and Blender are large projects using CMake. LLVM changed during the last two years and even Boost announced it will switch.

Upvotes: 1

arrowd
arrowd

Reputation: 34401

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.

Upvotes: 5

Related Questions