CMake or make. Do I need both?

New question. I recently came across a project that had a lot of files and external libraries. Some of these libraries included Makefile and CMakeLists.txt. I'm creating a similar project that includes external libraries. Do I need to learn both CMake and make. Or is CMake enough?

+3


source to share


3 answers


How to create a CMake concept

No need to learn how to write makefile

, as CMake is an abstraction layer or "meta-make" that generates makefiles for you. And like any abstraction layer, you just need to learn how to use its functions. But you also need to understand the task for which it was designed. In this case, for example, What is a build tool? or What is the built-in build environment?

What does the "c" in the cmake wall mean for?

But - in conjunction with , and cdash is much more than that, it (basically) removes the need to learn compiler / linker switches, your platforms / frameworks to handle libraries / executables and install them, etc.

  • Cross compilation
  • Cross-Platform
  • Cross-Language
    • It mainly supports C / C ++ but also supports for example Asm, RC, Fortran and CMake 3.8 C # version
    • It removes the need to learn other script languages ​​(often used for pre- or post-build steps) as it has a medium-sized inline script language.


Difference between using Makefile and cmake to compile code

From my experience using CMake in my projects:

  • Disadvantage: you need to test it in all target environments (admittedly nothing special for CMake). In a closed environment (for example within a company) it is relatively easy to maintain, but for example when setting up with open source there will always be this or that use case where you need to tweak the CMake script a bit.

  • Potential: CMake is widely used / supported in C / C ++ projects and gives me a potential user of your project the ability to use my build environment and make a selection tool (like I replaced make

    with ninja

    in my projects).

Links

+3


source


CMake is a meta build.

Using the cmake

and settings in CMakeLists.txt

, CMake will generate build files for the target platform. These can be Makefiles, Visual Studio solutions, Ninja files, KDevelop project files, ...



If the project is configured to use CMake, you don't even need to look at the generated buildfiles (Makefiles). They are strictly temporary.

+1


source


CMake is a Makefile (and other project files). You don't need to learn make

unless you intend to hook into CMake itself.

However, some classic knowledge make

is still useful, for example:

  • Passing a flag -j

    for parallel
  • make V=1

    for verbose output
  • make clean

    for the cleaning
  • make install

    and DESTDIR

    parameters
0


source







All Articles