>Neo/Vim bros using C/C++
How do you deal with Makefiles and cmake in your projects? Do you always write them from scratch, even in 2026?
i wrote a makefile template that i use for most personal projects i write in C, and write scripts for anything that it doesn't cover
you only have to modify a few lines
here, have it# Configuration
PROGRAM = <name of your program>
# Directories
SRC_DIRS += src
INC_DIRS += inc
LIB_DIRS +=
BIN_DIR = bin
# Compiler
CC = gcc
CFLAGS += -O3
DEFINES +=
LIBRARIES +=
# Script (Read Only)
# Lists
SRC_FILES = $(wildcard $(patsubst %,%/*.c,$(SRC_DIRS)))
SRC_TO_OBJ = $(addprefix ./$(BIN_DIR)/,$(addsuffix .o,$(notdir $(basename $1))))
OBJ_FILES = $(call SRC_TO_OBJ,$(SRC_FILES))
SRC_TO_DEP = $(addprefix ./$(BIN_DIR)/,$(addsuffix .d,$(notdir $(basename $1))))
DEP_FILES = $(call SRC_TO_DEP,$(SRC_FILES))
# Options
CFLAGS += $(foreach def,$(DEFINES),-D$(def))
CFLAGS += $(foreach dir,$(INC_DIRS),-I$(dir))
LDFLAGS += $(foreach dir,$(LIB_DIRS),-L$(dir)) -L$(BIN_DIR)
LDFLAGS += $(foreach lib,$(LIBRARIES),-l$(lib))
# Compiler
OUTPUT_COMMAND = $(CC) -o $(PROGRAM) $(OBJ_FILES) $(LDFLAGS)
# Targeter
define TARGETER
$(call SRC_TO_OBJ,$1) : $1 | $(BIN_DIR)
$(CC) -MD -MP -MT "$(call SRC_TO_DEP,$1) $$@" -c $(CFLAGS) -o $$@ $$<
endef
# Targets (Read Only)
.PHONY: all clean clean-d clean-o clean-x
all: $(PROGRAM)
clean: clean-d clean-o clean-x
clean-d:
rm -rf $(DEP_FILES)
clean-o:
rm -rf $(OBJ_FILES)
clean-x:
rm -rf $(PROGRAM)
$(PROGRAM): $(SRC_FILES) $(OBJ_FILES)
$(OUTPUT_COMMAND)
$(foreach src,$(SRC_FILES),$(eval $(call TARGETER,$(src))))
-include $(DEP_FILES)
>>109027504 (OP)
I'm using visual studio and I write cmakelists by hand.
The builtin microsoft build system is dogshit, and everyone recommends using cmake instead. It's the same story on clion, though I don't use it anymore.
I just have a template cmake for every projectCMAKE_MINIMUM_REQUIRED(VERSION 3.22)
PROJECT(project_name LANGUAGES CXX)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
SET(CMAKE_CXX_FLAGS "-Wall -Wextra -Wconversion -pedantic -std=c++98 -ggdb")
FILE(GLOB_RECURSE SOURCES
"src/*.cpp")
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES})
It works with clang, and should work with g++ too.
This one is good for 99% of projects. I do have some snippet to use mold instead of ld on linux.
Makefiles are nice too, cmake can integrate with make, but the other way around isn't really true. So for C++ I just stick to cmake.
>>109027504 (OP)
I just use makefiles and yes I write them by hand
I don't know what cmake does and don't really care either
>>109027504 (OP)
>How do you deal with Makefiles and cmake in your projects?
Just open the online manual and read it while going line by line.
>Do you always write them from scratch, even in 2026?
Haven't made anything in 2026 but if I did I'd probably just have a LLM make me a batch script to compile and skip the whole cmake fiasco.
>>109027543
cmake is a cross-platform build system that generates native build system files
it is extremely homosexual
yeah usually a makefile on the root of my project and I use \r to compile
>>109027531
Setting the CMAKE_CXX_FLAGS variable directly is bad practice because it overrides and overwrites the defaults set by cmake for the platform you're on, which can be annoying.
Prefertarget_compile_options(YourTargetName
PRIVATE
--List
-Of
--Compile
--options
)
>>109027504 (OP)
I just copy an old meson.build file and change it to fit my new project. Probs should script it instead.
I write CMake files from scratch, who in turn generate the Makefiles.
>>109027504 (OP)
No, I use meson because I'm not retarded. Syntax and documentation is 10x better, managing dependencies is much better and it just werks.
If you use cmake then at the very least make it generate ninja instead of makefiles. Makefiles are slow.
Cmake is terrible, if you must use it then prefer to do things the dumb way and NEVER use shitty features like modules, they're a massive waste of time.
>>109028021
while this is factually correct, you can't really do C++ without CMake, so you may as well stop being a whiny bitch, and learn to do it right. it's not too bad when done by the books.
>>109027504 (OP)
I use neovim and meson. idk if there's any LSP for meson, but it's so EZ it has been a breeze to write by hand anyway.
>>109027529
>LDFLAGS += $(foreach lib,$(LIBRARIES),-l$(lib))
Might miss some flags, consider using pkg-config
Neo/Vim sisters are you still falling for memes in 2026 or the vim was the last one for you?
What was the last meme 4chan tech you fallen for?
>>109029372
https://mesonbuild.com/
>>109029431
Shut the fuck up, I've been using (neo)vim for almost a decade now and I'm never going back. Works perfect for every single task. I never change my config except every 2 years or so.
>>109029452
What is a config? Is editing text too hard for you, or is it too easy?
I have been using the same CMake template since 2024
>>109029417
true, i didn't know about pkg-config when i wrote this years ago
good advice
>>109027553
In theory, but in practice it's not cross-platform for shit and doesn't even work on the same platform 90%+ of the time. Crazy how terribad it is, it's ruined C++ completely for me. I last used it ages ago before cmake took over everything like a plague, I came back recently and found all the old libraries that were useful are now impossible to build.
>>109032272
Oh, no. Not at all.
C is very childlike and obsolete actually.
Rust promotes a richer technological ecosystem refined with the appropriate safety disciplines, thus ensuring a more welcoming development environment.
Really user and developer-friendly, ready to assimilate and incorporate itself into the demands and requirements of future human necessities.
It's a microcosm and a reflection of inclusivity and harmony amongst all cultural backgrounds, and it won't discriminate against any development philosophy, race, creed, religion or sexual preference.
Rust is King.
>>109027504 (OP)
>Do you always write them from scratch
I wrote a good cmake file once and just copy/paste it for every project I do
Writing a cmake that isn't complete shit is neigh impossible. I was the wagie responsible for the big beautiful buildsystem rewrite and you just keep wondering wtf you're doing. FindPackage, downloading shit, working with vendored cmake deps, all the god damn configurations you expose and ultimately (I think the latest cmake fixes this??) maintaining your targets, their source files because lol glob bad and making sure you propagate c flags correctly. You still aren't completely free of linker ordering or other bizarre C(++) compiler/linker bullshit because they're all dogshit.
If you really want to make a greenfield project, just use Rust. Cargo literally just works and some wage cuck likely made a *-sys for any major C package you need anyway. Packages usually support both Unix and Windows targets, a lot of packages have a no_std for your SBCs or microcontrollers, literally why bother with C bullshit?
>>109027504 (OP)
LLMs are way better than humans at writing cmake. Cmake is a disaster. It's like it was designed to be unusable by humans.
>Hmm yeah, let's just make every shit create random global variables and you can't know which unless you read the documentation