[CMake] Fix installation of llvm-ranlib on multiconfig builder.
[oota-llvm.git] / tools / llvm-ar / install_symlink.cmake
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 if(UNIX)
6   set(LINK_OR_COPY create_symlink)
7   set(DESTDIR $ENV{DESTDIR})
8 else()
9   set(LINK_OR_COPY copy)
10 endif()
11
12 # CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286.
13 if( WIN32 )
14   set(EXECUTABLE_SUFFIX ".exe")
15 else()
16   set(EXECUTABLE_SUFFIX "")
17 endif()
18
19 set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
20
21 message("Creating llvm-ranlib")
22
23 execute_process(
24   COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "llvm-ar${EXECUTABLE_SUFFIX}" "llvm-ranlib${EXECUTABLE_SUFFIX}"
25   WORKING_DIRECTORY "${bindir}")