diff --git a/cmake/generic.cmake b/cmake/generic.cmake index 69f4ccae88471dfd5caf1ef2410c5aeefab7db3c..8842e8e21c6df224bb6341a4f7f526e3d61e92e1 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -819,20 +819,18 @@ function(brpc_library TARGET_NAME) cc_library("${TARGET_NAME}" SRCS "${brpc_library_SRCS}" DEPS "${TARGET_NAME}_proto" "${brpc_library_DEPS}") endfunction() -# copy_if_different from src_file to dst_file before barrier_target. -function(copy_if_different src_file dst_file barrier_target) - # this is a dummy target, should always be run to update ${dst_file} - add_custom_target(before_${barrier_target} ALL - DEPENDS before_${barrier_target}_custom_command - ) - add_dependencies(${barrier_target} before_${barrier_target}) +# copy_if_different from src_file to dst_file At the beginning of the build. +function(copy_if_different src_file dst_file) + get_filename_component(FILE_NAME ${dst_file} NAME_WE) - add_custom_command( - OUTPUT before_${barrier_target}_custom_command + # this is a dummy target for custom command, should always be run firstly to update ${dst_file} + add_custom_target(copy_${FILE_NAME}_command ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file} COMMENT "copy_if_different ${dst_file}" VERBATIM ) + + add_dependencies(extern_glog copy_${FILE_NAME}_command) endfunction() # create a dummy source file, then create a static library. diff --git a/paddle/fluid/framework/ir/CMakeLists.txt b/paddle/fluid/framework/ir/CMakeLists.txt index 81bd8a4adf4c3fe584416b0ea834221e739ab4d4..8787aa8a94a44c2c36868fea4b88ede5f91b19f4 100644 --- a/paddle/fluid/framework/ir/CMakeLists.txt +++ b/paddle/fluid/framework/ir/CMakeLists.txt @@ -4,7 +4,7 @@ file(WRITE ${pass_file} "// Generated by the paddle/fluid/framework/ir/CMakeList file(APPEND ${pass_file} "\#pragma once\n") file(APPEND ${pass_file} "\#include \"paddle/fluid/framework/ir/pass.h\"\n") -copy_if_different(${pass_file} ${pass_file_final} extern_glog) +copy_if_different(${pass_file} ${pass_file_final}) add_subdirectory(fuse_optimizer_ops_pass) add_subdirectory(memory_optimize_pass) diff --git a/paddle/fluid/operators/CMakeLists.txt b/paddle/fluid/operators/CMakeLists.txt index 23509773fa9e0697159f0365cc21ba84fb0ab1bf..012b16a6a05f3d5fec3636b0a790d4d67334295f 100644 --- a/paddle/fluid/operators/CMakeLists.txt +++ b/paddle/fluid/operators/CMakeLists.txt @@ -7,7 +7,7 @@ set(pybind_file ${PADDLE_BINARY_DIR}/paddle/fluid/pybind/pybind.h.tmp CACHE INTE set(pybind_file_final ${PADDLE_BINARY_DIR}/paddle/fluid/pybind/pybind.h) file(WRITE ${pybind_file} "// Generated by the paddle/fluid/operators/CMakeLists.txt. DO NOT EDIT!\n\n") -copy_if_different(${pybind_file} ${pybind_file_final} operator) +copy_if_different(${pybind_file} ${pybind_file_final}) add_subdirectory(math) add_subdirectory(controlflow) diff --git a/paddle/fluid/operators/jit/CMakeLists.txt b/paddle/fluid/operators/jit/CMakeLists.txt index ce1b566c0b847444fa2a5d6267094e024573fb4b..1c56efeab416e219206f38b82e124f95af495a3b 100644 --- a/paddle/fluid/operators/jit/CMakeLists.txt +++ b/paddle/fluid/operators/jit/CMakeLists.txt @@ -12,7 +12,7 @@ file(GLOB jit_kernel_cc_srcs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cc") list(REMOVE_ITEM jit_kernel_cc_srcs test.cc benchmark.cc) cc_library(jit_kernel_base SRCS ${jit_kernel_cc_srcs} DEPS ${JIT_KERNEL_DEPS}) -copy_if_different(${jit_file} ${jit_file_final} jit_kernel_base) +copy_if_different(${jit_file} ${jit_file_final}) # refer must go first add_subdirectory(refer)