Ninja generator: NDEBUG is not defined for RC files in release mode
Test setup
The test setup consists of a .cpp file and a .rc file that both output a message based on whether the NDEBUG
and _DEBUG
flags are set.
See attached file NDEBUG.zip
Expected behavior
Both the .exe file description (from the .rc file) and the program output (from the .cpp file) agree on the definition of NDEBUG and _DEBUG.
Actual behavior
With the Ninja generator, in Release mode, the NDEBUG macro is defined when compiling the .cpp file, but not when compiling the .rc file. With the MSBuild generator, the behavior is as expected.
Full output:
Ninja generator, debug build:
Output: _DEBUG is defined.
File description: _DEBUG is defined.
!! Ninja generator, release build:
!! Output: NDEBUG is defined
!! File description: Neither NDEBUG nor _DEBUG are defined.
"Visual Studio 15 2017 Win64" generator, debug build:
Output: _DEBUG is defined
File description: _DEBUG is defined
"Visual Studio 15 2017 Win64" generator, release build:
Output: NDEBUG is defined
File description: NDEBUG is defined
Environment
Using CMake 3.14.0 and Visual Studio 2017 on Windows 10.