Explorar o código

ctkMacroCompilePythonScript - Do not add Copy target to ALL

The "copy" target is a convenient target allowing to only copy the file
without recompiling.

By adding it to "ALL", two copy of each input files were
happening simultaneously. while doing parallel build, this could lead
to a race condition.
Jean-Christophe Fillion-Robin %!s(int64=14) %!d(string=hai) anos
pai
achega
4f6bf09b58
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      CMake/ctkMacroCompilePythonScript.cmake

+ 7 - 6
CMake/ctkMacroCompilePythonScript.cmake

@@ -32,6 +32,7 @@ MACRO(ctkMacroCompilePythonScript)
     SET(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
   ENDIF()
   
+  SET(input_files)
   SET(copied_files)
   SET(copied_python_files)
   FOREACH(file ${MY_SCRIPTS})
@@ -48,7 +49,8 @@ MACRO(ctkMacroCompilePythonScript)
       file(RELATIVE_PATH tgt_file ${CMAKE_CURRENT_BINARY_DIR} ${file})
       SET(tgt "${MY_DESTINATION_DIR}/${tgt_file}")
     ENDIF()
-
+    
+    LIST(APPEND input_files ${src})
     ADD_CUSTOM_COMMAND(DEPENDS ${src}
                         COMMAND ${CMAKE_COMMAND} -E copy ${src} ${tgt}
                         OUTPUT ${tgt}
@@ -62,6 +64,7 @@ MACRO(ctkMacroCompilePythonScript)
       SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
       SET(tgt "${MY_DESTINATION_DIR}/${file}")
       
+      LIST(APPEND input_files ${src})
       ADD_CUSTOM_COMMAND(DEPENDS ${src}
                           COMMAND ${CMAKE_COMMAND} -E copy ${src} ${tgt}
                           OUTPUT ${tgt}
@@ -70,11 +73,9 @@ MACRO(ctkMacroCompilePythonScript)
     ENDFOREACH()
   ENDIF()
            
-  IF(copied_files)
-    ADD_CUSTOM_TARGET(Copy${MY_TARGET_NAME}PythonFiles
-                      ALL
-                      DEPENDS ${copied_files})
-  ENDIF()  
+  IF(input_files)
+    ADD_CUSTOM_TARGET(Copy${MY_TARGET_NAME}PythonFiles DEPENDS ${input_files} ${copied_files})
+  ENDIF()
   
   # Byte compile the Python files.
   SET(compile_all_script "${CMAKE_CURRENT_BINARY_DIR}/compile_${MY_TARGET_NAME}_python_scripts.py")