title: CMake - compile with /MT instead of /MD
body: <p>I'm a newbie to cmake (2.8.12.1) and I'm using it on Windows to generate the project files to build cpp-netlib using Visual Studio 2012.</p>
  
  <p>By default it compiles with the /MDd compiler switch. I want to change it so that it uses /MTd.</p>
  
  <p>I followed the advice given here <a href="https://stackoverflow.com/a/14172871">https://stackoverflow.com/a/14172871</a> but it isn't working for me. </p>
  
  <p>Specifically, I added the second line shown below in the if statement to CmakeLists.txt.</p>
  
  <pre><code>if (MSVC)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
      set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
  endif()
  </code></pre>
  
  <p>When I open the Visual Studio sln file I can see that the /MDd option is still set. Furthermore, I see the following in CMakeCache.txt:</p>
  
  <pre><code>//Flags used by the compiler during debug builds.
  CMAKE_CXX_FLAGS_DEBUG:STRING=/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
  </code></pre>
  
  <p>I've also tried setting the flags from scratch like this:</p>
  
  <pre><code>set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
  </code></pre>
  
  <p>but that doesn't work either.</p>
  
  <p>If I pass the option via the command line like this:</p>
  
  <pre><code>-DCMAKE_CXX_FLAGS_DEBUG="/MTd"
  </code></pre>
  
  <p>the option is successfully set in the Visual Studio projects.</p>
  
  <p>Can anyone tell me what I'm doing wrong? </p>
  
  <p>I would also appreciate it if someone could enlighten me as to where the values in the cache come from that I don't specify on the command line or aren't in CmakeLists.txt.</p>
  
  <p>Adding CMakeList.txt as requested. I've never posted before so apologies if I've not done this right.</p>
  
  <pre><code># Original from cpp-netlib.org with my edits
  
  cmake_minimum_required(VERSION 2.8)
  project(CPP-NETLIB)
  set(Boost_USE_STATIC_LIBS ON)
  set(Boost_USE_MULTI_THREADED ON)
  find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options chrono )
  find_package( OpenSSL )
  find_package( Threads )
  set(CMAKE_VERBOSE_MAKEFILE true)
  
  if (CMAKE_BUILD_TYPE MATCHES Debug)
      add_definitions(-DBOOST_NETWORK_DEBUG)
  endif()
  
  if (OPENSSL_FOUND)
      add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
      include_directories(${OPENSSL_INCLUDE_DIR})
  endif()
  
  if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  endif()
  
  if (Boost_FOUND)
      ################# added #################
      add_definitions(-DBOOST_ALL_NO_LIB)
      #########################################
      if (MSVC)
        add_definitions(-D_SCL_SECURE_NO_WARNINGS)
      endif(MSVC)
      if (WIN32)
        add_definitions(-D_WIN32_WINNT=0x0501)
      endif(WIN32)
      include_directories(${Boost_INCLUDE_DIRS})
      enable_testing()
      add_subdirectory(libs/network/src)
      add_subdirectory(libs/network/test)
      if (NOT MSVC)
        add_subdirectory(libs/mime/test)
      endif(NOT MSVC)
      add_subdirectory(libs/network/example)
  endif(Boost_FOUND)
  
  if (MSVC)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
      ################# added #################
      set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
      #########################################
  endif()
  
  enable_testing()
  </code></pre>