1# We need to execute this script at installation time because the
2# DESTDIR environment variable may be unset at configuration time.
3# See PR8397.
4
5function(install_symlink name target outdir)
6  set(DESTDIR $ENV{DESTDIR})
7  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
8
9  message(STATUS "Creating ${name}")
10
11  execute_process(
12    COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
13    WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
14  if(CMAKE_HOST_WIN32 AND has_err)
15    execute_process(
16      COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
17      WORKING_DIRECTORY "${bindir}")
18  endif()
19
20endfunction()
21