-1

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
Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885

1 Answers1

0

I think I can provide a partial answer for <sdkddkver.h>. I don't have a solution for <winapifamily.h> that instills a lot of confidence.

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

It appears environmental variables are transformed to uppercase when made available as a Nmake macro, so the following worked as expected:

!IF "$(WINDOWSSDKDIR)" != "" || "$(WINDOWSSDKLIBVERSION)" != ""
CXXFLAGS = $(CXXFLAGS) /FI sdkddkver.h
!ENDIF

Here's the partial solution for <winapifamily.h>. Its OK for Windows Phone 8 and Windows 10. But its got a dead zone around Windows 8 with Visual Studio and SDKs installed. The dead zone is it fails to determine that <winapifamily.h> is available:

!IF "$(WINDOWSPHONEKITDIR)" != "" || "$(UNIVERSALCRTSDKDIR)" != "" || "$(UCRTVERSION)" != ""
CXXFLAGS = $(CXXFLAGS) /FI winapifamily.h
!ENDIF
jww
  • 97,681
  • 90
  • 411
  • 885