[cmake-developers] Silencing warning about environment when using NMake / JOM

James Johnston JamesJ at motionview3d.com
Wed Aug 5 11:17:41 EDT 2015


Hi,

While using the NMake and JOM generators in CMake, I have come across this
warning:

  To use the [NMake | JOM] generator, cmake must be run from a shell that
can use the
  compiler cl from the command line.  This environment does not contain
  INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
  work.

OK, so this is kind of a minor complaint, but this is an annoying warning if
you aren't actually wanting Visual C++ in your environment.  What if I was
wanting to use those generators without setting up a Visual C++ environment
with vcvarsall.bat?  Example use cases where this warning is annoying:

 * Using it to invoke a superbuild where: (1) the superbuild itself does not
use any languages (project command says NONE for languages), (2) the
superbuild sets up the VCVars environment uniquely for each
ExternalProject_Add.  For example, I might have ExternalProject_Add to build
both 32-bit and 64-bit versions of an ExternalProject.  And so I'd have
ExternalProject invoke VCVarsAll.bat uniquely for each environment.  In this
situation, running VCVars to silence the warning before invoking superbuild
is NOT good, because now I have two "nested" VCVars environments: (1) if the
VCVars invoked by the superbuild fails, it will be masked by the first call
to VCVars, meaning you could end up building for the wrong environment -
without error (VCVars doesn't return proper error codes), (2) and now you
have a PATH/LIB/INCLUDE that has combined paths for both 32-bit and 64-bit
building.

 * Using the NMake/JOM generators with non-Visual C++ compilers (which DOES
seem to work without issue otherwise).  In that case, of course I'm not
going to run VCVarsAll as a preliminary step...

I examined the CMake source code and found out that if either the INCLUDE or
LIB environment variables are missing, then the warning is emitted.  So I've
worked around it for now by setting both variables to a semicolon ";" in my
environment.  But this hack doesn't pass the smell test for me, starting
with the fact that it involves messing with my environment in a weird way
and ending with relying on an undocumented detail of CMake.

Can these warnings be either eliminated entirely or suppressed via a more
documented method?  I could probably provide a patch but I'm not sure which
direction to take with it.
       	
Best regards,

James Johnston




More information about the cmake-developers mailing list