# matlab\_add\_mex configures conflicting warning options for MSVC

**URL:** https://discourse.cmake.org/t/matlab-add-mex-configures-conflicting-warning-options-for-msvc/12727
**Category:** Development
**Tags:** comp:msvc
**Created:** [October 9, 2024, 6:03am UTC](https://discourse.cmake.org/t/matlab-add-mex-configures-conflicting-warning-options-for-msvc/12727 "2024-10-09T06:03:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mpitka](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@mpitka](https://discourse.cmake.org/u/mpitka)
#### Post date: [October 9, 2024, 6:03am UTC](https://discourse.cmake.org/t/matlab-add-mex-configures-conflicting-warning-options-for-msvc/12727/1 "2024-10-09T06:03:14Z")

</div>

Hi, CMake silences compiler warnings for `MEX_VERSION_FILE` (c\_mexapi\_version.c or cpp\_mexapi\_version.cpp) for a list of compilers with a `-w` switch. When building with the MSVC compiler, this creates a compiler warning about conflicting warning reporting settings if the user has previously set a different warning reporting level. This change seems to be implemented [in this commit](https://gitlab.kitware.com/cmake/cmake/-/commit/0576913aff83d90e3fae82d84b8e1ea02631d614).

The warning from MSVC could look e.g. like this  
`cl : command line warning D9025: overriding '/W3' with '/w'`

With at least some recent versions of MSVC, the rightmost conflicting option is used, in this case the one that suppresses the warnings, so the warning is mostly a nuisance. However, it does not seem possible to get rid of this warning by other means than suppressing compiler warnings for the whole mex target.

Would there be a way for CMake to overwrite the existing warning option for that file, rather than appending `-w` to the compiler options?
