blob: 1a04de931ff7e04f0aae00cfa952d739c09b4467 [file] [log] [blame]
Chris Bieneman2ec309f2015-09-14 23:09:06 +00001# 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
Chris Bieneman26751e12015-10-16 23:17:13 +00005function(install_symlink name target outdir)
Shoaib Meenaicb3923f2018-01-09 07:50:18 +00006 if(CMAKE_HOST_UNIX)
Chris Bieneman2ec309f2015-09-14 23:09:06 +00007 set(LINK_OR_COPY create_symlink)
8 set(DESTDIR $ENV{DESTDIR})
9 else()
10 set(LINK_OR_COPY copy)
11 endif()
12
Chris Bieneman26751e12015-10-16 23:17:13 +000013 set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
Chris Bieneman2ec309f2015-09-14 23:09:06 +000014
15 message("Creating ${name}")
16
17 execute_process(
Chris Bieneman26751e12015-10-16 23:17:13 +000018 COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}"
Chris Bieneman2ec309f2015-09-14 23:09:06 +000019 WORKING_DIRECTORY "${bindir}")
20
21endfunction()