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
5if(UNIX)
6  set(CLANGXX_LINK_OR_COPY create_symlink)
7  set(CLANGXX_DESTDIR $ENV{DESTDIR})
8else()
9  set(CLANGXX_LINK_OR_COPY copy)
10endif()
11
12# CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286.
13if( WIN32 )
14  set(EXECUTABLE_SUFFIX ".exe")
15else()
16  set(EXECUTABLE_SUFFIX "")
17endif()
18
19set(bindir "${CLANGXX_DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
20set(clang "clang${EXECUTABLE_SUFFIX}")
21set(clangxx "clang++${EXECUTABLE_SUFFIX}")
22set(clang_cl "clang-cl${EXECUTABLE_SUFFIX}")
23set(cl "cl${EXECUTABLE_SUFFIX}")
24
25message("Creating clang++ executable based on ${clang}")
26
27execute_process(
28  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clangxx}"
29  WORKING_DIRECTORY "${bindir}")
30
31message("Creating clang-cl executable based on ${clang}")
32
33execute_process(
34  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clang_cl}"
35  WORKING_DIRECTORY "${bindir}")
36
37if (WIN32)
38  message("Creating cl executable based on ${clang}")
39
40  execute_process(
41    COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "../msbuild-bin/${cl}"
42    WORKING_DIRECTORY "${bindir}")
43endif()
44