Answer the question
In order to leave comments, you need to log in
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
If everything is so simple now, then you need to understand make / cmake?
# 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
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.
As far as I understand make is no longer relevant.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question