Skip to content

Commit 272d1b4

Browse files
authored
[libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (llvm#85756)
In other contexts, install directories such as LIBCXX_INSTALL_LIBRARY_DIR and LIBCXX_INSTALL_MODULES_DIR can be specified either as a relative path, relative to CMAKE_INSTALL_PREFIX, or as an absolute path. When calculating the relative path between the two, account for the fact that LIBCXX_INSTALL_MODULES_DIR and LIBCXX_INSTALL_LIBRARY_DIR can be absolute paths too.
1 parent 11dd881 commit 272d1b4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libcxx/modules/CMakeLists.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,15 @@ 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+
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
210+
BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
211+
OUTPUT_VARIABLE ABS_LIBRARY_DIR)
212+
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
213+
BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
214+
OUTPUT_VARIABLE ABS_MODULES_DIR)
209215
file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
210-
${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
211-
${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
216+
${ABS_LIBRARY_DIR}
217+
${ABS_MODULES_DIR})
212218
configure_file(
213219
"modules.json.in"
214220
"${LIBCXX_LIBRARY_DIR}/libc++.modules.json"

0 commit comments

Comments
 (0)