Skip to content
Snippets Groups Projects
Forked from CMake / CMake
Source project has a limited visibility.
  • Brad King's avatar
    fff34934
    MSVC: Restore _DEBUG preprocessor definition in RC debug builds · fff34934
    Brad King authored
    In commit v3.8.0-rc1~304^2 (MSVC: Do not define _DEBUG explicitly when
    using /MDd, 2016-11-15) we removed the `_DEBUG` preprocessor definition
    from MSVC C and C++ flags because the `cl` compiler automatically
    defines it in Debug builds anyway.  However, the VS generators propagate
    C preprocessor definitions to the RC (Windows Resource Compiler) tool.
    This means that we used to explicitly define `_DEBUG` for RC debug
    builds.  Therefore existing project code may expect the definition to be
    there even though the `rc` compiler itself does not implicitly define
    `_DEBUG` in debug builds.
    
    Add the `_DEBUG` flag to the default `CMAKE_RC_FLAGS_DEBUG` instead
    to restore this definition for RC debug builds.  This also makes it
    available consistently in VS, Ninja, and Makefile generators.
    
    Fixes: #16745
    fff34934
    History
    MSVC: Restore _DEBUG preprocessor definition in RC debug builds
    Brad King authored
    In commit v3.8.0-rc1~304^2 (MSVC: Do not define _DEBUG explicitly when
    using /MDd, 2016-11-15) we removed the `_DEBUG` preprocessor definition
    from MSVC C and C++ flags because the `cl` compiler automatically
    defines it in Debug builds anyway.  However, the VS generators propagate
    C preprocessor definitions to the RC (Windows Resource Compiler) tool.
    This means that we used to explicitly define `_DEBUG` for RC debug
    builds.  Therefore existing project code may expect the definition to be
    there even though the `rc` compiler itself does not implicitly define
    `_DEBUG` in debug builds.
    
    Add the `_DEBUG` flag to the default `CMAKE_RC_FLAGS_DEBUG` instead
    to restore this definition for RC debug builds.  This also makes it
    available consistently in VS, Ninja, and Makefile generators.
    
    Fixes: #16745