From e0a9115e2804bb6bdd236028600c353bc5240f10 Mon Sep 17 00:00:00 2001 From: Zhou Wei <52485244+zhouwei25@users.noreply.github.com> Date: Wed, 29 Jul 2020 11:09:05 +0800 Subject: [PATCH] fix random compile failure due to missing file (#25661) --- cmake/generic.cmake | 16 +++++++--------- paddle/fluid/framework/ir/CMakeLists.txt | 2 +- paddle/fluid/operators/CMakeLists.txt | 2 +- paddle/fluid/operators/jit/CMakeLists.txt | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cmake/generic.cmake b/cmake/generic.cmake index 69f4ccae88..8842e8e21c 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 81bd8a4adf..8787aa8a94 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 23509773fa..012b16a6a0 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 ce1b566c0b..1c56efeab4 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) -- GitLab