0

When I load developer tools by:

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.7
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

and I try to generate build files for my C++ hello world app in CMD by:

cmake -G 'NMake Makefiles'

I get:

CMake Error: Could not create named generator 'NMake

Generators
Visual Studio 16 2019        = Generates Visual Studio 2019 project files.
                             Use -A option to specify architecture.
* Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
                             Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch]  = Generates Visual Studio 2008 project files.
                             Optional [arch] can be "Win64" or "IA64".
Borland Makefiles            = Generates Borland makefiles.
NMake Makefiles              = Generates NMake makefiles.
NMake Makefiles JOM          = Generates JOM makefiles.
Green Hills MULTI            = Generates Green Hills MULTI files
                             (experimental, work-in-progress).
MSYS Makefiles               = Generates MSYS makefiles.
MinGW Makefiles              = Generates a make file for use with
                             mingw32-make.

# etc.

But if I switch to PowerShell by writing powershell in CMD and run the same command:

cmake -G 'NMake Makefiles'

it's working correctly:

-- The C compiler identification is MSVC 19.16.27027.1
-- The CXX compiler identification is MSVC 19.16.27027.1

# etc.

Any idea why cmake is working in PowerShell but not in CMD?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Martin877
  • 263
  • 2
  • 10

1 Answers1

1

The Windows Command Prompt does not recognize single quotes as quoting characters. You must use double quotes instead.

Change

cmake -G 'NMake Makefiles'

to

cmake -G "NMake Makefiles"

and the problem will disappear.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328