6

I've read similar questions on stackoverflow but none of the answers did solve my problem.

I need to compile with /MDd flag and here is my CMake command: (note the bolded /MDd flag)

cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:/temp -DCMAKE_C_FLAGS="-Zi -W4 -WX- -Od -Oy- -D_WIN32 -DWIN32=1 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -D_CRT_SECURE_NO_WARNINGS=1 -D_SCL_SECURE_NO_WARNINGS=1 -D_MBCS -GF- -Gm -EHsc -RTCc -RTC1 -MDd -GS -Gy- -Qpar- -fp:precise -fp:except -Zc:wchar_t -Zc:forScope -GR -Gd -analyze- -errorReport:prompt"

This is the output when executing nmake :

cl : Command line warning D9025 : overriding '/MDd' with '/MTd'
cl : Command line warning D9025 : overriding '/W4' with '/W3'

Can somebody enlighten me as to what am I doing wrong here?

Fraser
  • 74,704
  • 20
  • 238
  • 215
codekiddy
  • 5,897
  • 9
  • 50
  • 80
  • 1
    Does this answer your question? [Compile with /MT instead of /MD using CMake](https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake) – Andreas Walter Jan 19 '20 at 11:20

1 Answers1

7

You'll probably find that somewhere in your CMakeLists.txt you have something like:

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W3 /MTd")

CMake appends the build-specific CMAKE_C_FLAGS_DEBUG flags to the general CMAKE_C_FLAGS, so your list of flags which is ultimately passed to the compiler contains:

... /MDd ... /MTd ... and ... /W4 ... /W3 ....

The right-most values override the previous ones and generate the warnings. To fix this, you just need to modify the CMakeLists.txt to not apply those incorrect flags.

Less likely is that the variable CMAKE_C_FLAGS is being manipulated in the CMakeLists.txt, but you can always check that too.

Fraser
  • 74,704
  • 20
  • 238
  • 215
  • "CMake appends the build-specific..." that's what i thought in the first palce but didn't know know how to deal with, tnx! – codekiddy Aug 14 '14 at 23:35