mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
handle non-existing symlink creation locations
This commit is contained in:
@@ -315,6 +315,9 @@ The following ``cmake -E`` commands are available only on UNIX:
|
||||
``create_symlink <old> <new>``
|
||||
Create a symbolic link ``<new>`` naming ``<old>``.
|
||||
|
||||
.. note::
|
||||
Path to where ``<new>`` symbolic link will be created has to exist beforehand.
|
||||
|
||||
Windows-specific Command-Line Tools
|
||||
-----------------------------------
|
||||
|
||||
|
||||
@@ -1486,6 +1486,9 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
|
||||
// Remove the destination file so we can always create the symlink.
|
||||
cmSystemTools::RemoveFile(toFile);
|
||||
|
||||
// Create destination directory if it doesn't exist
|
||||
cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(toFile));
|
||||
|
||||
// Create the symlink.
|
||||
if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
|
||||
std::ostringstream e;
|
||||
|
||||
3
Tests/RunCMake/file/INSTALL-SYMLINK-stdout.txt
Normal file
3
Tests/RunCMake/file/INSTALL-SYMLINK-stdout.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
-- Before Installing
|
||||
-- Installing: .*/Tests/RunCMake/file/INSTALL-SYMLINK-build/dst/current_dir_symlink
|
||||
-- After Installing
|
||||
13
Tests/RunCMake/file/INSTALL-SYMLINK.cmake
Normal file
13
Tests/RunCMake/file/INSTALL-SYMLINK.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
set(src "${CMAKE_CURRENT_BINARY_DIR}/src")
|
||||
set(dst "${CMAKE_CURRENT_BINARY_DIR}/dst")
|
||||
file(REMOVE RECURSE "${src}")
|
||||
file(REMOVE RECURSE "${dst}")
|
||||
|
||||
file(MAKE_DIRECTORY "${src}")
|
||||
execute_process(COMMAND
|
||||
${CMAKE_COMMAND} -E create_symlink source "${src}/current_dir_symlink")
|
||||
|
||||
message(STATUS "Before Installing")
|
||||
file(INSTALL FILES "${src}/current_dir_symlink"
|
||||
DESTINATION ${dst} TYPE DIRECTORY)
|
||||
message(STATUS "After Installing")
|
||||
@@ -36,4 +36,5 @@ run_cmake(GLOB-noexp-LIST_DIRECTORIES)
|
||||
|
||||
if(NOT WIN32 OR CYGWIN)
|
||||
run_cmake(GLOB_RECURSE-cyclic-recursion)
|
||||
run_cmake(INSTALL-SYMLINK)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user