moc: Unknown option -isystem

1.1k views Asked by At

I am trying to install score-p. It has standard build chain. I passed the configuration part successfully. Makefile was generated automatically after configuration. Then I did make and got an error. The problem is moc complains that -isystem is an unknown option. The option is embedded in QT_CPPFLAGS. If I delete this option then moc complains that too many input files were specified. What should I do?

$(editor_plugin_moc_o): ../src/GUI-qt/plugins/SourceCodeEditor/%.moc.cpp: $(SRC_ROOT)src/GUI-qt/plugins/SourceCodeEditor/%.h
    @echo "Create moc file $@"
    @$(MKDIR_P) ../src/GUI-qt/plugins/SourceCodeEditor
    @$(MOC) $(QT_CPPFLAGS) $(CUBE_INCLUDES) $(GUI_INCLUDES) $(CUBE_DEBUG_FLAGS) $(DEFINE_TRACE_BROWSER) $< -o $@
2

There are 2 answers

0
MadScientist On BEST ANSWER

The GCC -isystem option takes an argument, so it would be something like -isystem /some/dir/include. You can't just remove the -isystem option without removing its argument as well.

However, it seems likely that if you remove both of them you'll get compile errors because header files cannot be found.

I recommend you try turning the -isystem option into a normal -I option, that moc will understand:

@$(MOC) $(patsubst -isystem,-I,$(QT_CPPFLAGS)) $(CUBE_INCLUDES) $(GUI_INCLUDES) $(CUBE_DEBUG_FLAGS) $(DEFINE_TRACE_BROWSER) $< -o $@
0
user268396 On

Your dependency structure is a bit off:

You want something like:

%.o : %.moc.cpp %.cpp
    @echo "Normal compilation of object file goes here"

%.moc.cpp: %.cpp
    moc $(INCLUDES) $(DEFINES) -i $< -o $@

Note that the moc.cpp file and the source cpp file chain to the same object file (because the moc.cpp is really additional source code for your main cpp file which you let moc generate for you). Also note that you need to have a rule to actually generate that moc.cpp file, where you pass moc correct defines and includes. Finally: you do not pass moc things like -isystem or other compiler specific flags, just the defines & the includes.

See the documentation which has a complete section on moc with Makefiles at: http://doc.qt.io/qt-5/moc.html