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
5# Set to an arbitrary directory to silence GNUInstallDirs warnings
6# regarding being unable to determine libdir.
7set(CMAKE_INSTALL_LIBDIR "lib")
8include(GNUInstallDirs)
9
10function(install_symlink name target outdir)
11  set(DESTDIR $ENV{DESTDIR})
12  if(NOT IS_ABSOLUTE "${outdir}")
13    set(outdir "${CMAKE_INSTALL_PREFIX}/${outdir}")
14  endif()
15  set(outdir "${DESTDIR}${outdir}")
16
17  message(STATUS "Creating ${name}")
18
19  execute_process(
20    COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
21    WORKING_DIRECTORY "${outdir}" ERROR_VARIABLE has_err)
22  if(CMAKE_HOST_WIN32 AND has_err)
23    execute_process(
24      COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
25      WORKING_DIRECTORY "${outdir}")
26  endif()
27
28endfunction()
29