r248043 - [CMake] Refactoring and cleaning up clang symlink generation.
Chris Bieneman via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 14:15:54 PDT 2015
Author: cbieneman
Date: Fri Sep 18 16:15:54 2015
New Revision: 248043
URL: http://llvm.org/viewvc/llvm-project?rev=248043&view=rev
Log:
[CMake] Refactoring and cleaning up clang symlink generation.
Generation of clang symlinks now uses add_clang_symlink macro which uses add_llvm_symlink. Also the list of symlinks to generate is configurable via CLANG_LINKS_TO_CREATE.
This re-lands r248015, with fixes for clang symlinks to always be generated as part of the clang and install-clang targets.
Removed:
cfe/trunk/tools/driver/clang_symlink.cmake
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt
Modified: cfe/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=248043&r1=248042&r2=248043&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 18 16:15:54 2015
@@ -414,6 +414,12 @@ 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)
+ # Always generate install targets
+ llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+endmacro()
+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(BEFORE
Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=248043&r1=248042&r2=248043&view=diff
==============================================================================
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Fri Sep 18 16:15:54 2015
@@ -51,33 +51,6 @@ 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)
@@ -87,8 +60,13 @@ add_custom_target(install-clang
-DCMAKE_INSTALL_COMPONENT=clang
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-# Create the clang++ and clang-cl symlinks at installation time.
-install(SCRIPT clang_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
+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()
# Configure plist creation for OS X.
set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
Removed: cfe/trunk/tools/driver/clang_symlink.cmake
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/clang_symlink.cmake?rev=248042&view=auto
==============================================================================
--- cfe/trunk/tools/driver/clang_symlink.cmake (original)
+++ cfe/trunk/tools/driver/clang_symlink.cmake (removed)
@@ -1,43 +0,0 @@
-# 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()
More information about the cfe-commits
mailing list