In a makefile for GNU Make I use this idiom to test whether a file exists:
static:
ifeq ($(wildcard $(FileName)),)
# do something when the file doesn't exist
else
# do something different when it does
endif
But it doesn't work in NMake (fatal error U1000: syntax error : ')' missing in macro invocation
). How can I replace it? It would be perfect if the replacement works in both build systems.
Nmake can run preprocessor directives:
http://msdn.microsoft.com/en-us/library/7y32zxwh.aspx
The conditions can vary, but Exists() is one of them:
http://msdn.microsoft.com/en-us/library/8t2e8d78.aspx
!IF EXISTS(foo.txt)
Lastly you use a command-line, http://msdn.microsoft.com/en-us/library/wkxa7sac.aspx
!IF [cmd /C IF NOT EXIST "foo.txt" exit 1]
Either way, this should work, using either !IF above here is full example:
!IF !EXISTS(foo.txt)
!ERROR Unable to locate foo.
!ELSE
!MESSAGE I Found foo!
!ENDIF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With