Makefiles do not support .c++ files
tommitytom opened this issue · comments
What seems to be the problem?
I'm making a premake script for cap'n'proto and it uses the .c++
extension for its C++ source files. Adding these as files works fine in VS, but do not get picked up by the gmake2 generator.
workspace "Foo"
configurations { "Debug" }
project "Baz"
kind "StaticLib"
files { "test1.cpp", "test2.c++" }
$ premake5 gmake2 && make
Building configurations...
Running action 'gmake2'...
Generated Makefile...
Generated Baz.make...
Done (36ms).
"==== Building Baz (debug) ===="
Creating obj
test1.cpp
Creating bin/Debug
Linking Baz
What did you expect to happen?
I expected to see test2.c++
show up in the file list above.
What have you tried so far?
I tried to use a buildaction
to specify that .c++
files should be compiled but that didn't seem to work.
filter "files:**.c++"
buildaction "Compile"
What version of Premake are you using?
Note that although this says I am using a -dev version, I grabbed it directly from premake-5.0.0-beta2-linux.tar.gz
$ ./premake5 --version
premake5 (Premake Build Script Generator) 5.0.0-dev
Anything else we should know?
Generated Makefile:
# Alternative GNU Make workspace makefile autogenerated by Premake
ifndef config
config=debug
endif
ifndef verbose
SILENT = @
endif
ifeq ($(config),debug)
Baz_config = debug
else
$(error "invalid configuration $(config)")
endif
PROJECTS := Baz
.PHONY: all clean help $(PROJECTS)
all: $(PROJECTS)
Baz:
ifneq (,$(Baz_config))
@echo "==== Building Baz ($(Baz_config)) ===="
@${MAKE} --no-print-directory -C . -f Baz.make config=$(Baz_config)
endif
clean:
@${MAKE} --no-print-directory -C . -f Baz.make clean
help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " debug"
@echo ""
@echo "TARGETS:"
@echo " all (default)"
@echo " clean"
@echo " Baz"
@echo ""
@echo "For more information, see https://github.com/premake/premake-core/wiki"
Generated Baz.make:
# Alternative GNU Make project makefile autogenerated by Premake
ifndef config
config=debug
endif
ifndef verbose
SILENT = @
endif
.PHONY: clean prebuild
SHELLTYPE := posix
ifeq (.exe,$(findstring .exe,$(ComSpec)))
SHELLTYPE := msdos
endif
# Configurations
# #############################################
RESCOMP = windres
TARGETDIR = bin/Debug
TARGET = $(TARGETDIR)/Baz.lib
OBJDIR = obj
DEFINES +=
INCLUDES +=
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -s
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
# Per File Configurations
# #############################################
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/test1.o
OBJECTS += $(OBJDIR)/test1.o
# Rules
# #############################################
all: $(TARGET)
@:
$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
$(PRELINKCMDS)
@echo Linking Baz
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
$(TARGETDIR):
@echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif
$(OBJDIR):
@echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
clean:
@echo Cleaning Baz
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(TARGET)
$(SILENT) rm -rf $(GENERATED)
$(SILENT) rm -rf $(OBJDIR)
else
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
$(SILENT) if exist $(subst /,\\,$(GENERATED)) rmdir /s /q $(subst /,\\,$(GENERATED))
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
endif
prebuild: | $(OBJDIR)
$(PREBUILDCMDS)
ifneq (,$(PCH))
$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)
$(GCH): $(PCH) | prebuild
@echo $(notdir $<)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) touch "$@"
else
$(SILENT) echo $null >> "$@"
endif
else
$(OBJECTS): | prebuild
endif
# File Rules
# #############################################
$(OBJDIR)/test1.o: test1.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
-include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH))
-include $(PCH_PLACEHOLDER).d
endif
filter { "files:**.c++" }
compileas "C++"
Should do the trick for gmake2. (not or partially supported by other generators).
See compileas
for details.
@tommitytom Please confirm if this works
Nudging this to see if it resolved the issue.