I have a directory with a Makefile, and a subdirectory, .\subdir, with its own Makefile. I am trying to call nmake from the top Makefile like so
SUB_DIR=.\subdir
test.exe:
$(MAKE) -C $(SUB_DIR)
when I run nmake I just get this message
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\nmake.exe" -C .\subdir
and nothing happens. When I manually cd into the subdir and run nmake, it works fine.
The -C
option used by nmake
is completely different from its meaning in make
. Rather than changing directories, it suppresses most messages, including errors. See https://learn.microsoft.com/en-us/cpp/build/reference/running-nmake?view=msvc-170. So "nothing happens".
The work-around is simple. Your makefile should be more like this:
SUB_DIR=.\subdir
test.exe:
cd $(SUB_DIR) && $(MAKE) -l
(The final -l
is the same as /NOLOGO
.)