Skip to content

Instantly share code, notes, and snippets.

@mishurov
Last active October 7, 2024 18:16
Show Gist options
  • Save mishurov/8134532 to your computer and use it in GitHub Desktop.
Save mishurov/8134532 to your computer and use it in GitHub Desktop.
Makefile to build QT projects (Linux) without qmake
CC=g++
MOC=moc-qt4
CFLAGS=-Wall
SOURCES=hello.cc hello_cls.cc
MOC_HEADERS=hello_cls.h
EXECUTABLE=hello
INCDIRS=-I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore
LIBS=-lQtCore -lQtGui
# Change postfixes
MOC_SOURCES=$(MOC_HEADERS:.h=.moc.cc)
OBJECTS=$(SOURCES:.cc=.o) $(MOC_SOURCES:.cc=.o)
all: $(EXECUTABLE)
@echo Done!
$(EXECUTABLE): $(OBJECTS)
$(CC) $^ $(LIBS) -o $@
# Generate object files, rule to change postfix
%.o: %.cc
$(CC) $(CFLAGS) $(INCDIRS) -c $< -o $@
# Generate cc from h via Qt's Meta Object Compiler, rule to change postfix
%.moc.cc: %.h
$(MOC) $(INCDIRS) $< -o $@
.PHONY: tags clean
clean:
rm *.o
# Generate ctags file for all included files (autocomplete and jump to source)
tags:
gcc -M $(INCDIRS) $(SOURCES) | \
sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$$/d' -e '/\.o:[ \t]*$$/d' | \
ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
@mishurov
Copy link
Author

mishurov commented Aug 7, 2023

@habaneropep2019 it is as old as mammoth shite. I'm working on time series rendered on GPU and QML.

@habaneropep2019
Copy link

@mishurov is there any chance I could get your permission to include your makefile with my Qt fork, under GPLv2 or BSD?

@mishurov
Copy link
Author

mishurov commented Aug 7, 2023

Why even ask that. Sure, of course. I'm not a lawyer. Everything I share, it is for public use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment