forked from STEllAR-GROUP/hpx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHPX_CreateSymbolicLink.cmake
38 lines (37 loc) · 1.25 KB
/
HPX_CreateSymbolicLink.cmake
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
36
37
38
# Copyright (c) 2017 Denis Blank
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# Creates a symbolic link from the destination to the target, if the link
# doesn't exist yet. Since `create_symlink` is only available for unix
# derivates, we work around that in this macro.
function(create_symbolic_link SYM_TARGET SYM_DESTINATION)
if(WIN32)
if(NOT EXISTS ${SYM_DESTINATION})
if(IS_DIRECTORY ${SYM_TARGET})
# Create a directory junction
execute_process(
COMMAND
cmd /C
"${PROJECT_SOURCE_DIR}/cmake/scripts/create_symbolic_link_directory.bat"
${SYM_DESTINATION} ${SYM_TARGET}
)
else()
# Create a file link
execute_process(
COMMAND
cmd /C
"${PROJECT_SOURCE_DIR}/cmake/scripts/create_symbolic_link_file.bat"
${SYM_DESTINATION} ${SYM_TARGET}
)
endif()
endif()
else()
# Only available on unix derivates
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink ${SYM_TARGET}
${SYM_DESTINATION}
)
endif()
endfunction(create_symbolic_link)