Index: modules/FindQt4.cmake
===================================================================
--- modules/FindQt4.cmake	(revision 659502)
+++ modules/FindQt4.cmake	(working copy)
@@ -880,12 +880,23 @@
      QT4_GET_MOC_INC_DIRS(moc_includes)
 
      GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
+     
+     IF (MSVC_IDE)
+        SET (_moc_parameter_file ${outfile}_parameters)
+        SET (_moc_param "${moc_includes} \n-o${outfile} \n${abs_infile}")
+        STRING(REGEX REPLACE ";-I;" "\\n-I" _moc_param "${_moc_param}")
+        FILE (WRITE ${_moc_parameter_file} "${_moc_param}")
+        ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
+          COMMAND ${QT_MOC_EXECUTABLE}
+          ARGS @"${_moc_parameter_file}"
+          DEPENDS ${abs_infile})
+     ELSE (MSVC_IDE)
+        ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
+          COMMAND ${QT_MOC_EXECUTABLE}
+          ARGS ${moc_includes} -o ${outfile} ${abs_infile}
+          DEPENDS ${abs_infile})
+     ENDIF (MSVC_IDE)
 
-     ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
-        COMMAND ${QT_MOC_EXECUTABLE}
-        ARGS ${moc_includes} -o ${outfile} ${abs_infile}
-        DEPENDS ${abs_infile})
-
      SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE)  # dont run automoc on this file
 
      MACRO_ADD_FILE_DEPENDENCIES(${abs_infile} ${outfile})
Index: modules/KDE4Macros.cmake
===================================================================
--- modules/KDE4Macros.cmake	(revision 659502)
+++ modules/KDE4Macros.cmake	(working copy)
@@ -185,11 +185,23 @@
                   message(FATAL_ERROR "In the file \"${_abs_FILE}\" the moc file \"${_current_MOC}\" is included, but \"${_abs_PATH}/${_basename}.h\" doesn't exist.")
                endif (NOT EXISTS ${_abs_PATH}/${_basename}.h)
 
-               add_custom_command(OUTPUT ${_moc}
-                  COMMAND ${QT_MOC_EXECUTABLE}
-                  ARGS ${_moc_INCS} ${_header} -o ${_moc}
-                  MAIN_DEPENDENCY ${_header}
-               )
+               if (MSVC_IDE)
+                  set (_moc_parameter_file ${_moc}_parameters)
+                  set (_moc_param "${_moc_INCS} \n${_header} \n-o${_moc}")
+                  string(REGEX REPLACE ";-I;" "\\n-I" _moc_param "${_moc_param}")
+                  file (WRITE ${_moc_parameter_file} "${_moc_param}")
+                  add_custom_command(OUTPUT ${_moc}
+                    COMMAND ${QT_MOC_EXECUTABLE}
+                    ARGS @"${_moc_parameter_file}"
+                    MAIN_DEPENDENCY ${_header}
+                  )
+               else (MSVC_IDE)
+                  add_custom_command(OUTPUT ${_moc}
+                     COMMAND ${QT_MOC_EXECUTABLE}
+                     ARGS ${_moc_INCS} ${_header} -o ${_moc}
+                     MAIN_DEPENDENCY ${_header}
+                  )               
+               endif (MSVC_IDE)
 
                list(APPEND _moc_FILES_PROPERTY ${_moc})
 
