Conflicting target names cause ’nmake test‘ to do nothing

Today I ran into a problem with using Microsoft’s nmake to build a project whose Makefile had been created by CMake. The build process ran fine but when I tried to run the test by calling „nmake test“, nmake just prompted

'test' is up-to-date

(in German: ‚test‘ ist aktuell). I was baffled, because under Linux it worked like a clockwork.

Thanks to Google, I found some IRC chat log where someone had had exactly the same problem and it was actually quite simple: My tests were located in a subdirectory called ‚test‘ and this name interfered with the make target ‚test‘ for running the tests. When Nmake was told to make target ‚test‘, it found the directory ‚test‘ existing already and thus prompted „‚test‘ is up-to-date“.

I changed the directory name to ‚tests‘. After that, calling ’nmake test‘ correctly executed my tests!