Skip to content

Commit dee8f8a

Browse files
committed
Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR
This reapplies 272d1b4 (from llvm#85756), which was reverted in 4079370. In the previous attempt, empty CMAKE_INSTALL_PREFIX was handled by quoting them, in d209d13. That made the calls to cmake_path(ABSOLUTE_PATH) succeed, but the output paths of that weren't actually absolute, which was required by file(RELATIVE_PATH). Avoid this issue by appending a slash to CMAKE_INSTALL_PREFIX, so we always get an absolute path, even if CMAKE_INSTALL_PREFIX was empty.
1 parent de0abc0 commit dee8f8a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

libcxx/modules/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,18 @@ add_custom_target(generate-cxx-modules
206206
# Configure the modules manifest.
207207
# Use the relative path between the installation and the module in the json
208208
# file. This allows moving the entire installation to a different location.
209+
#
210+
# Using a trailing slash in BASE_DIRECTORY, to produce a seemingly valid
211+
# absolute path, even if CMAKE_INSTALL_PREFIX is empty.
212+
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
213+
BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/"
214+
OUTPUT_VARIABLE ABS_LIBRARY_DIR)
215+
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
216+
BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/"
217+
OUTPUT_VARIABLE ABS_MODULES_DIR)
209218
file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
210-
${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
211-
${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
219+
${ABS_LIBRARY_DIR}
220+
${ABS_MODULES_DIR})
212221
configure_file(
213222
"modules.json.in"
214223
"${LIBCXX_LIBRARY_DIR}/libc++.modules.json"

0 commit comments

Comments
 (0)