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 link_or_copy)
11  # link_or_copy is the "command" to pass to cmake -E.
12  # It should be either "create_symlink" or "copy".
13
14  set(DESTDIR $ENV{DESTDIR})
15  if(NOT IS_ABSOLUTE "${outdir}")
16    set(outdir "${CMAKE_INSTALL_PREFIX}/${outdir}")
17  endif()
18  set(outdir "${DESTDIR}${outdir}")
19
20  message(STATUS "Creating ${name}")
21
22  execute_process(
23    COMMAND "${CMAKE_COMMAND}" -E ${link_or_copy} "${target}" "${name}"
24    WORKING_DIRECTORY "${outdir}")
25
26endfunction()
27