0

I'm using nmake inference rules successfully for file extensions -- but what about adding a file prefix? I'm doing qt stuff, so given a list of files eg

MOCS=moc_file1.cpp moc_file2.cpp

I want to find an an inference rule to get .h filenames to use as input to moc.exe and create the .cpp files.

rwhenderson
  • 84
  • 1
  • 6

1 Answers1

1

NMAKE inference rules allow specifying prefixes to the extensions referred in the rule. E.g.:

{$(SRCDIR)}.cpp{$(INTDIR)}.obj :
  $(CXX) $(CXXFLAGS) /Fo$@  /c $<

this rule would get triggered for [inferred] targets like:

"$(INTDIR)\somefile.obj" : "$(SRCDIR)\somefile.cpp"

Notice the use of {} braces to enclose the prefixes.

Similarly, an NMAKE inference batch rule (works on multiple source files at once):

{$(SRCDIR)}.cpp{$(INTDIR)}.obj ::
  $(CXX) $(CXXFLAGS) /Fo"$(INTDIR)"\  /c $<

Check out the official NMAKE docs -- they're still applicable even to VS2012.

vmsnomad
  • 319
  • 2
  • 7