Merged in domu/premake-dev-domu (pull request #46)
[gmake] allow mixing c files in cpp projects
This commit is contained in:
commit
23256ecc94
@ -142,8 +142,9 @@
|
||||
-- Build command for a single file.
|
||||
--
|
||||
|
||||
function cpp.buildcommand(prj, objext)
|
||||
local flags = iif(prj.language == "C", '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')
|
||||
function cpp.buildcommand(prj, objext, node)
|
||||
local iscfile = node and path.iscfile(node.abspath) or false
|
||||
local flags = iif(prj.language == "C" or iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')
|
||||
_p('\t$(SILENT) %s -o "$@" -MF $(@:%%.%s=%%.d) -c "$<"', flags, objext)
|
||||
end
|
||||
|
||||
@ -184,7 +185,7 @@
|
||||
local objectname = project.getfileobject(prj, node.abspath)
|
||||
_p('$(OBJDIR)/%s.o: %s', make.esc(objectname), make.esc(node.relpath))
|
||||
_p('\t@echo $(notdir $<)')
|
||||
cpp.buildcommand(prj, "o")
|
||||
cpp.buildcommand(prj, "o", node)
|
||||
|
||||
-- resource file
|
||||
elseif path.isresourcefile(node.abspath) then
|
||||
|
@ -45,6 +45,25 @@ $(OBJDIR)/hello1.o: src/hello.cpp
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- C files in C++ projects should been compiled as c
|
||||
--
|
||||
|
||||
function suite.cFilesGetsCompiledWithCCWhileInCppProject()
|
||||
files { "src/hello.c", "src/test.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
$(OBJDIR)/hello.o: src/hello.c
|
||||
@echo $(notdir $<)
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
|
||||
$(OBJDIR)/test.o: src/test.cpp
|
||||
@echo $(notdir $<)
|
||||
$(SILENT) $(CXX) $(ALL_CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
|
||||
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a custom build rule is supplied, it should be used.
|
||||
--
|
||||
|
Reference in New Issue
Block a user