Skip to content

Commit

Permalink
Merge pull request #5034 from llvm-beanz/fix-swiftshims-dependency
Browse files Browse the repository at this point in the history
[CMake] Fix bad dependency in symlink_clang_headers
  • Loading branch information
Chris B committed Sep 28, 2016
2 parents e53d0e2 + 58ca217 commit 3f0adbd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
26 changes: 26 additions & 0 deletions cmake/modules/SwiftComponents.cmake
Expand Up @@ -122,3 +122,29 @@ function(swift_install_in_component component)
install(${ARGN})
endif()
endfunction()

function(swift_install_symlink_component component)
cmake_parse_arguments(
ARG # prefix
"" "LINK_NAME;TARGET;DESTINATION" "" ${ARGN})
precondition(ARG_LINK_NAME MESSAGE "LINK_NAME is required")
precondition(ARG_TARGET MESSAGE "TARGET is required")
precondition(ARG_DESTINATION MESSAGE "DESTINATION is required")

swift_is_installing_component("${component}" is_installing)
if (NOT is_installing)
return()
endif()

foreach(path ${CMAKE_MODULE_PATH})
if(EXISTS ${path}/LLVMInstallSymlink.cmake)
set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
break()
endif()
endforeach()
precondition(INSTALL_SYMLINK
MESSAGE "LLVMInstallSymlink script must be available.")

install(SCRIPT ${INSTALL_SYMLINK}
CODE "install_symlink(${ARG_LINK_NAME} ${ARG_TARGET} ${ARG_DESTINATION})")
endfunction()
24 changes: 5 additions & 19 deletions stdlib/public/SwiftShims/CMakeLists.txt
Expand Up @@ -80,22 +80,8 @@ add_custom_command_target(unused_var
"${clang_headers_location}"
"${SWIFTLIB_DIR}/clang"

# Create a broken symlink that points to '../clang/$VERSION'. It is not
# used when running Swift tools from the build tree directly, but we will
# install it in such a way that it points to Clang installation. If the
# link can be resolved, CMake would try to follow it when installing the
# project under certain conditions.
COMMAND
"${CMAKE_COMMAND}" "-E" "make_directory" "${SWIFTLIB_DIR}/install-tmp/install-tmp"
COMMAND
"${CMAKE_COMMAND}" "-E" "remove"
"${SWIFTLIB_DIR}/install-tmp/install-tmp/clang"
COMMAND
"${CMAKE_COMMAND}" "-E" "create_symlink"
"../clang/${CLANG_VERSION}"
"${SWIFTLIB_DIR}/install-tmp/install-tmp/clang"
CUSTOM_TARGET_NAME "symlink_clang_headers"
OUTPUT "${SWIFTLIB_DIR}/clang" "${SWIFTLIB_DIR}/install-tmp/install-tmp/clang"
OUTPUT "${SWIFTLIB_DIR}/clang"
COMMENT "Symlinking Clang resource headers into ${SWIFTLIB_DIR}/clang")
add_dependencies(copy_shim_headers symlink_clang_headers)

Expand All @@ -110,10 +96,10 @@ swift_install_in_component(clang-builtin-headers
DESTINATION "lib/swift/clang"
PATTERN "*.h")

# Alternatively, install a symbolic link to the Clang resource directory.
swift_install_in_component(clang-resource-dir-symlink
DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift/install-tmp/install-tmp/clang"
DESTINATION "lib/swift")
swift_install_symlink_component(clang-resource-dir-symlink
LINK_NAME clang
TARGET ../clang/${CLANG_VERSION}
DESTINATION "lib/swift")

# Possibly install Clang headers under Clang's resource directory in case we
# need to use a different version of the headers than the installed Clang. This
Expand Down

0 comments on commit 3f0adbd

Please sign in to comment.