blob: 65973a57135a695526ba01afe760edbc4a73c5bd [file] [log] [blame]
Chris Bieneman6d43afc2015-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
5function(install_symlink name target)
6 if(UNIX)
7 set(LINK_OR_COPY create_symlink)
8 set(DESTDIR $ENV{DESTDIR})
9 else()
10 set(LINK_OR_COPY copy)
11 endif()
12
13 # CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286.
14 if( WIN32 )
15 set(EXECUTABLE_SUFFIX ".exe")
16 else()
17 set(EXECUTABLE_SUFFIX "")
18 endif()
19
20 set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
21
22 message("Creating ${name}")
23
24 execute_process(
25 COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}${EXECUTABLE_SUFFIX}" "${name}${EXECUTABLE_SUFFIX}"
26 WORKING_DIRECTORY "${bindir}")
27
28endfunction()