Skip to content

Commit 32c260c

Browse files
authored
"fix operators cmake" (#13581)
* "fix operators cmake" * "rerun ci" test=develop
1 parent 4c90c40 commit 32c260c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

paddle/fluid/framework/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# windows treat symbolic file as a real file, which is different with unix
23
# We create a hidden file and compile it instead of origin source file.
34
function(windows_symbolic TARGET)
@@ -9,11 +10,23 @@ function(windows_symbolic TARGET)
910
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc OR NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cu)
1011
message(FATAL " ${src}.cc and ${src}.cu must exsits, and ${src}.cu must be symbolic file.")
1112
endif()
12-
add_custom_command(OUTPUT .${src}.cu
13+
14+
# only copy the xx.cu to .xx.cu when the content are modified
15+
set(copy_flag 1)
16+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu)
17+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc SOURCE_STR)
18+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu TARGET_STR)
19+
if (SOURCE_STR STREQUAL TARGET_STR)
20+
set(copy_flag 0)
21+
endif()
22+
endif()
23+
if (copy_flag)
24+
add_custom_command(OUTPUT .${src}.cu
1325
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu
1426
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc" "${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu"
1527
COMMENT "create hidden file of ${src}.cu")
16-
add_custom_target(${TARGET} ALL DEPENDS .${src}.cu)
28+
endif(copy_flag)
29+
add_custom_target(${TARGET} ALL DEPENDS .${src}.cu)
1730
endforeach()
1831
endfunction()
1932

@@ -81,6 +94,8 @@ nv_test(data_device_transform_test SRCS data_device_transform_test.cu
8194

8295
if(WITH_GPU)
8396
if (WIN32)
97+
# windows treat symbolic file as a real file, which is different with unix
98+
# We create a hidden file and compile it instead of origin source file.
8499
windows_symbolic(hidden_file SRCS data_type_transform.cu)
85100
nv_library(data_type_transform SRCS .data_type_transform.cu DEPS tensor)
86101
add_dependencies(data_type_transform hidden_file)

0 commit comments

Comments
 (0)