mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
The Ninja and Makefile generators passed the install-name directory of a shared library (`@rpath/` by default, or `INSTALL_NAME_DIR`) through `ConvertToOutputFormat(SHELL)`. That converts directory separators for the host shell, so a Windows host cross-compiling for macOS wrote `-install_name @rpath\libfoo.dylib`. The install name is not a host path: it is embedded in the Mach-O load command and read by dyld on the target, where a backslash never matches anything. Escape the value for the shell without converting separators, in both generators. Add a test to each that fakes an install-name platform and checks the generated build files keep the forward slashes. Fixes: #28104
13 lines
535 B
CMake
13 lines
535 B
CMake
# The install-name directory is target data embedded in the binary, so it
|
|
# must keep its forward slashes on every host.
|
|
set(build_ninja "${RunCMake_TEST_BINARY_DIR}/build.ninja")
|
|
file(READ "${build_ninja}" content)
|
|
foreach(expected "INSTALLNAME_DIR = @rpath/\n" "INSTALLNAME_DIR = /custom/dir/\n")
|
|
string(FIND "${content}" "${expected}" pos)
|
|
if(pos EQUAL -1)
|
|
string(STRIP "${expected}" expected)
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"${build_ninja} does not contain the line:\n ${expected}\n")
|
|
endif()
|
|
endforeach()
|