U
U
Unuxlinuxbog2016-09-22 04:35:50
linux
Unuxlinuxbog, 2016-09-22 04:35:50

Should I learn build automation?

Goodnight. As far as I understand make is no longer relevant. They use qmake, cmake. And in some IDEs, cmake, qmake are generated by themselves. If everything is so simple now, then you need to understand make / cmake? Why is cmake fundamentally better than make? Recommend a good book on assembly, please. Please tell us more about this topic. Sorry for the noob questions. Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
abcd0x00, 2016-09-22
@abcd0x00

If everything is so simple now, then you need to understand make / cmake?

In general, make is an old, proven tool that is everywhere. And practice shows that when you have a project, you need to not only compile it, but also maintain it in every possible way (run tests, clean unnecessary files, install, uninstall). And for all this, only one Makefile can be made, since in it you can not only build, but also set a series of commands.
Homemade Makefile Example
# Build section

CC = gcc
CFLAGS = -ansi -pedantic -Wall

TARGET = ntow
OBJS = main.o noun.o triple.o number.o cmdline.o errors.o input.o

BASEDIR = .
TESTDIR = $(BASEDIR)/tests

# Install section

prefix = /usr/local

PREFIX = $(prefix)
BINDIR = $(PREFIX)/bin

# Rules

all: $(TARGET)

$(TARGET): $(OBJS)
  @$(CC) $(CFLAGS) $^ -o [email protected] && echo "$(TARGET) has built"

main.o: cmdline.h number.h input.h errors.h
triple.o: triple.h
number.o: number.h
cmdline.o: cmdline.h errors.h

# Commands

help:
  @echo "usage: make [ test | install | uninstall | clean | cleanall ]" 1>&2

test: $(TARGET)
  @$(MAKE) -C $(TESTDIR) run

clean:
  @rm -f $(OBJS) $(TARGET) && echo "$(TARGET) cleaned"

cleanall: clean
  @$(MAKE) -C $(TESTDIR) clean

install:
  install -d $(BINDIR)
  install $(TARGET) $(BINDIR)/$(TARGET)

uninstall:
  rm -f $(BINDIR)/$(TARGET)

.PHONY: help all test clean cleanall install uninstall

A
Ariox41, 2016-09-22
@Ariox41

IDEs support cmake quite poorly so far, but the situation is changing for the better. In any case, it will not be possible to use it without knowing it at all, except for simple cases.
As for the advantages: the main advantage of cmake is that it can independently set flags for the desired compiler and can search for popular libraries if the appropriate environment variables are set. The latest versions are able to work with header-only libraries. In addition, it contains the CPack and CTest utilities. I can't say anything about CPack, but CTest is quite convenient for testing, and it can be combined with gtest and analogues.
And I would not try to write a makefile for a cross-platform application / library with tests and external dependencies myself, cmake will do it better.

O
Oleg Tsilyurik, 2016-09-22
@Olej

As far as I understand make is no longer relevant.

Misunderstood.
CMake only generates a Makefile for subsequent make.
But not in all cases and not always successfully.
Those. it is fundamentally not better, but worse than make.
Here: Development of software projects in Linux
And there is an excellent complete translation of the make documentation, it is indicated at the link above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question