title: Compile Boost with multi-configuration with CMake
body: <p>I have a project which depends on the Boost library (and others). I created a CMakeLists to automatically download and compile dependencies with <code>ExternalProject_Add</code>.</p>
  
  <p>I want to support multi-configuration (Release and Debug). So, for my other libraries I defined a <code>CMAKE_BUILD_TYPE</code> at the beginning of my CMakeLists. I propagate it by dependencies with <code>-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}</code> in  the <code>ExternalProject_Add</code> command.</p>
  
  <p>It works well on Windows and Linux.</p>
  
  <p>For Boost however, based on the configuration I need to compile with <code>variant=debug</code> or <code>variant=release</code>. I created a <code>if(${CMAKE_BUILD_TYPE) MATCHES Debug)</code> statement and set the variant based on that requirement.</p>
  
  <p>For Linux this works well but on Windows it works only if I change the <code>CMAKE_BUILD_TYPE</code> variable during the <code>cmake</code>. When I try to change the configuration in VS it doesn't change the <code>CMAKE_BUILD_TYPE</code> variable.</p>
  
  <p>Is it possible to detect the configuration selected in VS in my CMakeLists ?</p>
  
  <p>Thank you.</p>
  
  <pre><code>#-----------------------------------------------------------------------------
  # Boost
  #-----------------------------------------------------------------------------
  
  message(STATUS "Installing Boost library.")
  
  set(BOOST_BOOTSTRAP_COMMAND)
  if(WIN32)
    set(BOOST_BOOTSTRAP_COMMAND bootstrap.bat)
    set(BOOST_B2_COMMAND b2.exe)
  elseif(UNIX )
    set(BOOST_BOOTSTRAP_COMMAND ./bootstrap.sh)
    set(BOOST_B2_COMMAND ./b2)
  else()
    # MacOSX
    set(BOOST_BOOTSTRAP_COMMAND ./bootstrap.sh)
    set(BOOST_B2_COMMAND ./b2)
  endif()
  
  set(BOOST_BUILD_TYPE variant=release)
  if (${CMAKE_BUILD_TYPE} MATCHES Debug)
    set(BOOST_BUILD_TYPE variant=debug)
  endif(${CMAKE_BUILD_TYPE} MATCHES Debug)
  
  set(BOOST_INSTALL_DIR ${PROJECT_BINARY_DIR}/deps/boost-install)
  ExternalProject_Add(boost
    SOURCE_DIR "${PROJECT_BINARY_DIR}/deps/boost"
    BUILD_IN_SOURCE 1
    GIT_REPOSITORY "${git_protocol}://github.com/boostorg/boost"
    GIT_TAG "5ec478a570bdc71c5d4854e7165a8b3f4fa82ad9"
    CONFIGURE_COMMAND ${BOOST_BOOTSTRAP_COMMAND}
    BUILD_COMMAND ${BOOST_B2_COMMAND} headers COMMAND ${BOOST_B2_COMMAND} install
      link=static
      ${BOOST_BUILD_TYPE}
      --prefix=${BOOST_INSTALL_DIR}
      --with-filesystem
      --with-program_options
      --with-system
      --with-thread
      -j8
    INSTALL_COMMAND ""
  )
  </code></pre>