[libcxx-commits] [libcxx] [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (PR #85756)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 19 01:56:35 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Martin Storsjö (mstorsjo)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/85756.diff
1 Files Affected:
- (modified) libcxx/modules/CMakeLists.txt (+13-2)
``````````diff
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 0dea8cfca94ac3..08deb452f5579a 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -203,12 +203,23 @@ add_custom_target(generate-cxx-modules
${_all_modules}
)
+
+function(make_absolute OUT_VAR INPUT BASE)
+ if (IS_ABSOLUTE ${INPUT})
+ set(${OUT_VAR} "${INPUT}" PARENT_SCOPE)
+ else()
+ set(${OUT_VAR} "${BASE}/${INPUT}" PARENT_SCOPE)
+ endif()
+endfunction()
+
# Configure the modules manifest.
# Use the relative path between the installation and the module in the json
# file. This allows moving the entire installation to a different location.
+make_absolute(ABS_LIBRARY_DIR "${LIBCXX_INSTALL_LIBRARY_DIR}" "${CMAKE_INSTALL_PREFIX}")
+make_absolute(ABS_MODULES_DIR "${LIBCXX_INSTALL_MODULES_DIR}" "${CMAKE_INSTALL_PREFIX}")
file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
- ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
- ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
+ ${ABS_LIBRARY_DIR}
+ ${ABS_MODULES_DIR})
configure_file(
"modules.json.in"
"${LIBCXX_LIBRARY_DIR}/libc++.modules.json"
``````````
</details>
https://github.com/llvm/llvm-project/pull/85756
More information about the libcxx-commits
mailing list