Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 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 | function(install_symlink name target outdir) |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 6 | set(DESTDIR $ENV{DESTDIR}) |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 7 | if(CMAKE_HOST_UNIX) |
| 8 | set(LINK_OR_COPY create_symlink) |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 9 | else() |
| 10 | set(LINK_OR_COPY copy) |
| 11 | endif() |
| 12 | |
| 13 | set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/") |
| 14 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 15 | message(STATUS "Creating ${name}") |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 16 | |
| 17 | execute_process( |
| 18 | COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}" |
| 19 | WORKING_DIRECTORY "${bindir}") |
| 20 | |
| 21 | endfunction() |