Use NMAKE to make all source in a directory?

后端 未结 6 1426
盖世英雄少女心
盖世英雄少女心 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:33

    You can run a shell command during nmakefile preprocessing, and then !include the output. Naturally the output needs to be in nmake format. Something like:

    !if [bash -c "echo O = *.cpp" >sources.mak]
    !error Failed to generate source list
    !endif
    !include sources.mak
    
    all: $(O:.cpp=.obj)
    
    .cpp.obj:
        ---COMPILE $< HERE---
    

    I suspect that most people would not use bash to create sources.mak, but you get the idea.

提交回复
热议问题