Use NMAKE to make all source in a directory?

后端 未结 6 1429
盖世英雄少女心
盖世英雄少女心 2021-01-21 15:57

Using nmake, is it possible to have the makefile build all the .cpp files in the current directory automatically, without having to specify them individually?

So, instea

6条回答
  •  借酒劲吻你
    2021-01-21 16:24

    You can use a rule like this:

    {src\mystuff}.c{tmp\src\mystuff}.obj::
        $(CC) /nologo $(CFLAGS) /c /Fotmp\src\mystuff\ $<
    

    which will find and compile all the .c files in src\mystuff and put the object files in tmp\src\mystuff. Substitute .cpp for .c in your case.

    Note that the first character on the second line should be a tab, not spaces.

    Also, $(CC) is predefined by nmake to be cl, and you can add any compiler flags you need to $(CFLAGS), hard-code them in the rule or add a different variable there, as you prefer.

提交回复
热议问题