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
18 lines
805 B
CMake
18 lines
805 B
CMake
enable_language(C)
|
|
|
|
# Pretend the platform supports install names, as Darwin does, so that the
|
|
# generator writes the install-name directory on every host.
|
|
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
|
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name ")
|
|
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
|
|
set(CMAKE_C_CREATE_SHARED_LIBRARY
|
|
"<CMAKE_C_COMPILER> <SONAME_FLAG><TARGET_INSTALLNAME_DIR><TARGET_SONAME> -o <TARGET> <OBJECTS>")
|
|
|
|
add_library(rpath_dir SHARED hello.c)
|
|
set_property(TARGET rpath_dir PROPERTY AIX_SHARED_LIBRARY_ARCHIVE OFF)
|
|
|
|
add_library(custom_dir SHARED hello.c)
|
|
set_property(TARGET custom_dir PROPERTY INSTALL_NAME_DIR "/custom/dir")
|
|
set_property(TARGET custom_dir PROPERTY BUILD_WITH_INSTALL_NAME_DIR ON)
|
|
set_property(TARGET custom_dir PROPERTY AIX_SHARED_LIBRARY_ARCHIVE OFF)
|