ソースを参照

ctkscriptMocPythonQtWrapper - On windows, moc flags are dumped to a file

Writing the moc flags to a file should prevent the "too long input"
error from happening on windows.
Jean-Christophe Fillion-Robin 14 年 前
コミット
9acf399935
共有2 個のファイルを変更した19 個の追加0 個の削除を含む
  1. 11 0
      CMake/ctkMacroWrapPythonQt.cmake
  2. 8 0
      CMake/ctkScriptMocPythonQtWrapper.cmake

+ 11 - 0
CMake/ctkMacroWrapPythonQt.cmake

@@ -277,7 +277,18 @@ MACRO(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
   FOREACH(flag ${moc_flags})
     SET(moc_flags_arg "${moc_flags_arg}^^${flag}")
   ENDFOREACH()
+
+  # On Windows, to avoid "too long input" error, dump moc flags.
+  IF(WIN32)
+    # File containing the moc flags
+    SET(wrapper_moc_flags_filename mocflags_${WRAPPING_NAMESPACE_UNDERSCORE}_${TARGET}_all.txt)
+    SET(wrapper_master_moc_flags_file ${CMAKE_CURRENT_BINARY_DIR}/${wrap_int_dir}${wrapper_moc_flags_filename})
+    FILE(WRITE ${wrapper_master_moc_flags_file} ${moc_flags_arg})
+    # The arg passed to the custom command will be the file containing the list of moc flags
+    SET(moc_flags_arg ${wrapper_master_moc_flags_file})
+  ENDIF()
   
+  # File to run through moc
   SET(wrapper_master_moc_filename moc_${WRAPPING_NAMESPACE_UNDERSCORE}_${TARGET}_all.cpp)
   SET(wrapper_master_moc_file ${CMAKE_CURRENT_BINARY_DIR}/${wrap_int_dir}${wrapper_master_moc_filename})
   

+ 8 - 0
CMake/ctkScriptMocPythonQtWrapper.cmake

@@ -51,6 +51,14 @@ ENDFOREACH()
 # Convert wrapping namespace to subdir
 STRING(REPLACE "." "_" WRAPPING_NAMESPACE_UNDERSCORE ${WRAPPING_NAMESPACE})
 
+# Read moc flags from file
+IF(WIN32)
+  IF(NOT EXISTS ${MOC_FLAGS})
+    MESSAGE(SEND_ERROR "On Windows, MOC_FLAGS should be the name of the file containing the moc flags !")
+  ENDIF()
+  FILE(READ ${MOC_FLAGS} MOC_FLAGS)
+ENDIF()
+
 # Convert ^^ separated string to list
 STRING(REPLACE "^^" ";" MOC_FLAGS "${MOC_FLAGS}")