简体   繁体   中英

CMake: How to treat every resource compiler warning as error and to suppress specific warnings?

To suppress specific warning in specific source file when using CMake to generate MSVC projects I'm using something like:

set_source_files_properties(
    "ToursInfoMng.cpp"
  PROPERTIES
    COMPILE_FLAGS "/wd4503")

This doesn't work for resource compiler warnings. For example for warning:

warning RC4206: title string too long; truncated at 256

I tried to use:

set_source_files_properties(
    "ResEs.rc"
  PROPERTIES
    COMPILE_FLAGS "/wd4206")

but this doesn't suppress the warning.

  • How to suppress resource compiler warning properly?
  • How to treat resource compiler warnings which are not suppressed as errors?

I'm using \\WX for both compiler and linker warnings setting it to CMAKE_CXX_FLAGS and CMAKE_STATIC|SHARED|EXE_LINKER_FLAGS respectively, but I don't know how to do it for resource compiler warnings.

I don't believe either of these is possible. There are no documented general warning control options for the Windows Resource Compiler, just type rc /? to check.

You can change the Resource Compiler's flags using CMAKE_RC_FLAGS .

There is also a filter on COMPILE_FLAGS and COMPILE_OPTIONS that prevents them being used to pass any flags that are not defines or includes to the Resource Compiler. In principle, if you needed to, you could change the filter ( CMAKE_RC_FLAG_REGEX ) so as to be able to use these properties for more, but that would not help you in this situation.

#pragma warning(push)
#pragma warning(disable : 4101)
// Function Here : Declare
#pragma warning(pop)

Then If you want To suppress specific warnings for Visual C++ Following this ref : https://msdn.microsoft.com/en-us/library/jj715718.aspx

Press Ctrl+F > Type "To suppress specific warnings for Visual C++". You can find how to suppress specific warnings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM