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
5include(GNUInstallDirs)
6
7function(install_symlink name target outdir)
8  set(DESTDIR $ENV{DESTDIR})
9  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
10
11  message(STATUS "Creating ${name}")
12
13  execute_process(
14    COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
15    WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
16  if(CMAKE_HOST_WIN32 AND has_err)
17    execute_process(
18      COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
19      WORKING_DIRECTORY "${bindir}")
20  endif()
21
22endfunction()
23