-
Notifications
You must be signed in to change notification settings - Fork 42
/
CMakeLists.txt.rename_artifact.in
35 lines (25 loc) · 1.25 KB
/
CMakeLists.txt.rename_artifact.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This file is only used on Windows, so that we may clean up after ourselves.
#
# This script is called from CMakeLists.txt.island_prolog - doing so appears to
# be the only way to ensure that any FILE EXISTS checks happen at compile time
# and not at configure time.
if (${Method} MATCHES Rename)
if(EXISTS ${FileToCheck})
# message(STATUS "${FileToCheck} exists.")
STRING ( RANDOM rand_str )
get_filename_component(dir_name ${FileToCheck} DIRECTORY )
get_filename_component(file_name_without_longest_extension ${FileToCheck} NAME_WE )
get_filename_component(file_name_longest_extension ${FileToCheck} EXT )
set ( generated_file_name "${dir_name}${file_name_without_longest_extension}_${rand_str}${file_name_longest_extension}.old")
# message(STATUS "Generated filename: '${generated_file_name}'")
FILE ( RENAME ${FileToCheck} ${generated_file_name} )
# note that we only *attempt* to remove the old file, it's okay if we don't succeed in case
# another process still holds onto the file (which may be the case for .dll files while hot-
# reloading.)
FILE ( REMOVE ${generated_file_name} )
else()
# message(STATUS "${FileToCheck} doesn't exist.")
endif()
elseif (${Method} MATCHES Touch)
FILE ( TOUCH ${FileToCheck} )
endif()