From 7c8ac35f5584d1b4efd893caa46141fa3a2abacc Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Fri, 18 Sep 2015 19:59:51 +0000 Subject: [PATCH] Revert "[CMake] Refactoring and cleaning up clang symlink generation." This reverts commit r248015, because it broke bots. I'll revise and recommit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248025 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 8 ------ tools/driver/CMakeLists.txt | 36 ++++++++++++++++++++------ tools/driver/clang_symlink.cmake | 43 ++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 tools/driver/clang_symlink.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 83a34ecfef..8b9025970a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,14 +414,6 @@ macro(add_clang_executable name) set_clang_windows_version_resource_properties(${name}) endmacro(add_clang_executable) -macro(add_clang_symlink name dest) - add_llvm_tool_symlink(${name} ${dest}) - # Always generate install targets - if(LLVM_INSTALL_TOOLCHAIN_ONLY) - llvm_install_symlink(${name} ${dest}) - endif() -endmacro() - set(CMAKE_INCLUDE_CURRENT_DIR ON) include_directories(BEFORE diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index c2cc539350..c966b0b6c5 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -51,6 +51,33 @@ endif() add_dependencies(clang clang-headers) +if(UNIX) + set(CLANGXX_LINK_OR_COPY create_symlink) +# Create a relative symlink + set(clang_binary "clang${CMAKE_EXECUTABLE_SUFFIX}") +else() + set(CLANGXX_LINK_OR_COPY copy) + set(clang_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}") +endif() + +# Create the clang++ symlink in the build directory. +set(clang_pp "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}") +add_custom_command(TARGET clang POST_BUILD + COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_pp}" + WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}") + +set_property(DIRECTORY APPEND + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_pp}) + +# Create the clang-cl symlink in the build directory. +set(clang_cl "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}") +add_custom_command(TARGET clang POST_BUILD + COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" "${clang_cl}" + WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}") + +set_property(DIRECTORY APPEND + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_cl}) + install(TARGETS clang RUNTIME DESTINATION bin COMPONENT clang) @@ -60,13 +87,8 @@ add_custom_target(install-clang -DCMAKE_INSTALL_COMPONENT=clang -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") -if(NOT CLANG_LINKS_TO_CREATE) - set(CLANG_LINKS_TO_CREATE clang++ clang-cl) -endif() - -foreach(link ${CLANG_LINKS_TO_CREATE}) - add_clang_symlink(${link} clang) -endforeach() +# Create the clang++ and clang-cl symlinks at installation time. +install(SCRIPT clang_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\") # Configure plist creation for OS X. set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name") diff --git a/tools/driver/clang_symlink.cmake b/tools/driver/clang_symlink.cmake new file mode 100644 index 0000000000..c01259543c --- /dev/null +++ b/tools/driver/clang_symlink.cmake @@ -0,0 +1,43 @@ +# We need to execute this script at installation time because the +# DESTDIR environment variable may be unset at configuration time. +# See PR8397. + +if(UNIX) + set(CLANGXX_LINK_OR_COPY create_symlink) + set(CLANGXX_DESTDIR $ENV{DESTDIR}) +else() + set(CLANGXX_LINK_OR_COPY copy) +endif() + +# CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286. +if( WIN32 ) + set(EXECUTABLE_SUFFIX ".exe") +else() + set(EXECUTABLE_SUFFIX "") +endif() + +set(bindir "${CLANGXX_DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/") +set(clang "clang${EXECUTABLE_SUFFIX}") +set(clangxx "clang++${EXECUTABLE_SUFFIX}") +set(clang_cl "clang-cl${EXECUTABLE_SUFFIX}") +set(cl "cl${EXECUTABLE_SUFFIX}") + +message("Creating clang++ executable based on ${clang}") + +execute_process( + COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clangxx}" + WORKING_DIRECTORY "${bindir}") + +message("Creating clang-cl executable based on ${clang}") + +execute_process( + COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clang_cl}" + WORKING_DIRECTORY "${bindir}") + +if (WIN32) + message("Creating cl executable based on ${clang}") + + execute_process( + COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "../msbuild-bin/${cl}" + WORKING_DIRECTORY "${bindir}") +endif() -- 2.40.0