BundleUtilities: Ensure target dir exists when creating symlinks

Commit v3.13.0-rc1~279^2 (GetPrerequisites: Move dylibs from MacOS
to Frameworks folder in bundle, 2018-07-22) introduced a regression
that can cause symlink creation to fail during packaging. Symlinks
can be created before targets are installed, so the destination
directory of the symlink sometimes won't exist at symlink creation.

Fixes: #18726
This commit is contained in:
Tim Blechmann 2018-12-11 23:48:53 +08:00 committed by Craig Scott
parent 9bbfbd54ba
commit 200bf57742

View File

@ -720,6 +720,9 @@ function(link_resolved_item_into_bundle resolved_item resolved_embedded_item)
else()
get_filename_component(target_dir "${resolved_embedded_item}" DIRECTORY)
file(RELATIVE_PATH symlink_target "${target_dir}" "${resolved_item}")
if (NOT EXISTS "${target_dir}")
file(MAKE_DIRECTORY "${target_dir}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${symlink_target}" "${resolved_embedded_item}")
endif()
endfunction()