blob: 09fed8085c23e27a4a322240b7b094b011c91c1f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001# 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)
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006 set(DESTDIR $ENV{DESTDIR})
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01007 if(CMAKE_HOST_UNIX)
8 set(LINK_OR_COPY create_symlink)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01009 else()
10 set(LINK_OR_COPY copy)
11 endif()
12
13 set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
14
Andrew Walbran3d2c1972020-04-07 12:24:26 +010015 message(STATUS "Creating ${name}")
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010016
17 execute_process(
18 COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}"
19 WORKING_DIRECTORY "${bindir}")
20
21endfunction()