We have a Nmake-based makefile to help with testing under Visual Studio, including Visual Studio .Net/2002 through Visual Studio 2015. The makefile includes the following:
CXXFLAGS = /nologo /W4 /wd4511 /D_MBCS /Zi /TP /GR /EHsc /MD /FI sdkddkver.h /FI winapifamily.h
LDFLAGS = /nologo /SUBSYSTEM:CONSOLE
ARFLAGS = /nologo
LDLIBS =
It works great under later Visual Studios, like 2015 Developer Command prompt, because <sdkddkver.h>
and <winapifamily.h>
are always available from the SDKs. Testing under Visual Studio 2008 on Windows 7, or Visual Studio 2005 on Windows Vista, does not go so well:
> nmake /f cryptest.nmake
cl.exe /nologo /D_MBCS /Zi /TP /GR /EHsc /MD /FI sdkddkver.h /FI winapifamily.h /Yc"pch.h" /Fp"pch.pch" /c pch.cpp
pch.cpp
pch.cpp : fatal error C1083: Cannot open include file: 'winapifamily.h': No such
file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\
VC\BIN\cl.exe"' : return code '0x2'
Stop.
We would like to guard the force includes based on the availability of <sdkddkver.h>
and <winapifamily.h>
. I checked the environment using set
and Nmake's environment with nmake -p
, but nothing is jumping out at me.
How can we detect when <sdkddkver.h>
and <winapifamily.h>
are available from a Visual Studio Developer command prompt?
This is kind of the step before Platform defined macros for windows store app. I think the following are similar or related questions, but they assume the files we are trying to detect are already present:
Here are two attempts which I know don't work when testing under VS2015:
# Both WindowsSdkDir and WindowsSdkVersion are defined in environment
!IF "$(WindowsSdkDir)" != "" || "$(WindowsSdkVersion)" != ""
CXXFLAGS = $(CXXFLAGS) /FI sdkddkver.h
!ENDIF
And:
!IF EXIST(sdkddkver.h)
CXXFLAGS = $(CXXFLAGS) /FI sdkddkver.h
!ENDIF