Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake overriding my /MDd flag with /MTd [duplicate]

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?

like image 575
codekiddy Avatar asked Aug 14 '14 10:08

codekiddy


1 Answers

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.

like image 153
Fraser Avatar answered Sep 24 '22 14:09

Fraser