[Cmake] Setting different compiler flags for Debug vs Release builds

William A. Hoffman billlist at nycap . rr . com
Fri, 17 Oct 2003 12:05:35 -0400


At 06:10 PM 10/16/2003, Mathews, Rob wrote:
>Thanks, I'd be happy to give it a whirl.
>
>But, how to you use it to set a different runtime library? It turns out to
>be pretty important to be able to set the RuntimeLibrary tag in the .vcproj
>file ... 

You set the run time library with the /M* flags in the CMAKE_CXX_FLAGS.

Here is the mapping to the runtime flags:
  if(flags.find("MTd") != flags.npos)
    {
    runtime = 1;
    }
  else if (flags.find("MDd") != flags.npos)
    {
    runtime = 3;
    }
  else if (flags.find("MLd") != flags.npos)
    {
    runtime = 5;
    }
  else if (flags.find("MT") != flags.npos)
    {
    runtime = 0;
    }
  else if (flags.find("MD") != flags.npos)
    {
    runtime = 2;
    }
  else if (flags.find("ML") != flags.npos)
    {
    runtime = 4;
    }

This way the same CMakeLists.txt file should work for visual studio 7 and 6.


>While we are here, there is a problem with .IDL files as well. Cmake
>generates this for .IDL files: 
> <Tool
>        Name="VCCLCompilerTool"
>        AdditionalOptions=" /TP "
>/>
>
>It should generate: 
><Tool
>        Name="VCMIDLTool"
>        AdditionalOptions=""
>/>

I will look at this problem as well.


-Bill