@@ -471,7 +471,7 @@ endif()
471
471
# rebuild step. The long-term fix should be to clean up these rules so they
472
472
# only rerun when needed.
473
473
474
- if (BUILD_PYTHON AND BUILD_CAFFE2_OPS )
474
+ if (BUILD_PYTHON )
475
475
# Python site-packages
476
476
# Get canonical directory for python site packages (relative to install
477
477
# location). It varies from system to system.
@@ -628,37 +628,22 @@ if (BUILD_PYTHON AND BUILD_CAFFE2_OPS)
628
628
endif ()
629
629
630
630
# Finally, Copy all python files to build directory
631
- # Generate and create all needed __init__.py files, if they aren't already
632
- # present in the current source tree.
633
- message (STATUS "Automatically generating missing __init__.py files." )
634
- caffe_autogen_init_py_files ()
635
-
636
631
# Create a custom target that copies all python files.
637
632
file (GLOB_RECURSE PYTHON_SRCS RELATIVE ${PROJECT_SOURCE_DIR}
638
633
"${PROJECT_SOURCE_DIR} /caffe2/*.py" )
639
- add_custom_target (python_copy_files ALL )
640
- if (MSVC OR CMAKE_GENERATOR MATCHES "Ninja" )
641
- # ninja fails when the command line is too long so we split
642
- # the target into several. This would be beneficial for VS also
643
- # since it build targets in parallel but not custom commands
644
- foreach (python_src ${PYTHON_SRCS} )
645
- get_filename_component (dir ${python_src} DIRECTORY )
646
- string (SHA1 name_hash "${python_src} " )
647
- # get_filename_component(name_we ${python_src} NAME_WE)
648
- add_custom_target (python_copy_files_${name_hash}
649
- COMMAND ${CMAKE_COMMAND} -E copy
650
- ${PROJECT_SOURCE_DIR} /${python_src} ${CMAKE_BINARY_DIR} /${dir} )
651
- add_dependencies (python_copy_files python_copy_files_${name_hash} )
652
- endforeach ()
653
- else ()
654
- foreach (python_src ${PYTHON_SRCS} )
655
- get_filename_component (dir ${python_src} DIRECTORY )
656
- add_custom_command (
657
- TARGET python_copy_files PRE_BUILD
658
- COMMAND ${CMAKE_COMMAND} -E copy
659
- ${PROJECT_SOURCE_DIR} /${python_src} ${CMAKE_BINARY_DIR} /${dir} )
660
- endforeach ()
661
- endif ()
634
+
635
+ set (build_files )
636
+ foreach (python_src ${PYTHON_SRCS} )
637
+ add_custom_command (OUTPUT ${CMAKE_BINARY_DIR} /${python_src}
638
+ DEPENDS ${PROJECT_SOURCE_DIR} /${python_src}
639
+ COMMAND ${CMAKE_COMMAND} -E copy
640
+ ${PROJECT_SOURCE_DIR} /${python_src}
641
+ ${CMAKE_BINARY_DIR} /${python_src} )
642
+ list (APPEND build_files ${CMAKE_BINARY_DIR} /${python_src} )
643
+ endforeach ()
644
+
645
+ add_custom_target (python_copy_files ALL DEPENDS ${build_files} )
646
+
662
647
663
648
# Install commands
664
649
# Pick up static python files
0 commit comments