Open beserge opened 2 years ago
And at some point, we add support for *.c++ files endings? Hmmm... Wouldn't it make sense to specify the file ending directly in the CPP_SOURCES list instead?
@TheSlowGrowth I was kind of thinking the same thing.
It'd be nice if we could just append to the CPP_SOURCES
and just have a list of acceptable suffixes.
I think @beserge and I both tried quick hacks on the existing recipes to do that, but it didn't work quite right. Admittedly, my make
chops aren't the best.
Would something as simple as this replacement of the separate CC_SOURCES
list work as expected?
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cc=.o)))
vpath %.cc $(sort $(dir $(CPP_SOURCES)))
@stephenhensley I did a little poking. Your exact proposal does not work as-is because the current OBJECTS
append invocations will pass through file names in the relevant source lists that don't end with the correct extension.
As in, $(CPP_SOURCES:.cpp=.o)
will reassign .cpp
extensions in the list to .o
but leave non-matching extensions unchanged.
However this works (filter CPP_SOURCES
into two sub lists, each containing exclusively .cpp
or .cc
files)
CPP_SOURCES_CPP = $(filter %.cpp, $(CPP_SOURCES))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES_CPP:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES_CPP)))
CPP_SOURCES_CC = $(filter %.cc, $(CPP_SOURCES))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES_CC:.cc=.o)))
vpath %.cc $(sort $(dir $(CPP_SOURCES_CC)))
This is actually a little more foolproof in general because it ensures that no files with incompatible extensions make it through to OBJECTS
. In fact it might be good to add a similar filter statement to the C_SOURCES
object append invocation as well.
Add CC_SOURCES and .cc compilation to core/Makefile