Question

I'm using a find command in a makefile like so:

CC = clang++
CODE = $(shell find . -name *.cpp) #find command here !!!!!!
EXEC = tcr_translator

.PHONY: all clean

all: $(OBJECT)
    clear
    $(CC) $(CODE) -o $(EXEC) -I src/

clean:
    rm $(EXEC)

run: all
    ./tcr_translator

So, this find command list all the cpp file to compile, makes it easier than to hard-write them in my makefile. This worked perfectly for my last project, so I took the same makefile for my new project. My problem, now the find command (which is, char for char, the same command) won't look into my subdirectories. So if I have .cpp in a src/ subfolder, it won't find them.

Why would such a command work in a certain directory and not in an other. I'm really at a loss here :(

Was it helpful?

Solution

You should quote the *.cpp to avoid it from being expanded by shell before passed into find.

CODE = $(shell find . -name '*.cpp')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top