1
+
1
2
# windows treat symbolic file as a real file, which is different with unix
2
3
# We create a hidden file and compile it instead of origin source file.
3
4
function (windows_symbolic TARGET )
@@ -9,11 +10,23 @@ function(windows_symbolic TARGET)
9
10
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${src}.cc OR NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${src}.cu )
10
11
message (FATAL " ${src} .cc and ${src} .cu must exsits, and ${src} .cu must be symbolic file." )
11
12
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
13
25
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR} /.${src}.cu
14
26
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR} /${src} .cc" "${CMAKE_CURRENT_SOURCE_DIR} /.${src} .cu"
15
27
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 )
17
30
endforeach ()
18
31
endfunction ()
19
32
@@ -81,6 +94,8 @@ nv_test(data_device_transform_test SRCS data_device_transform_test.cu
81
94
82
95
if (WITH_GPU )
83
96
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.
84
99
windows_symbolic (hidden_file SRCS data_type_transform.cu )
85
100
nv_library (data_type_transform SRCS .data_type_transform.cu DEPS tensor )
86
101
add_dependencies (data_type_transform hidden_file )
0 commit comments