[llvm-branch-commits] [libcxx] release/18.x: [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#85756) (PR #85907)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Mar 20 08:58:51 PDT 2024
Martin =?utf-8?q?Storsjö?= <martin at martin.st>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/85907 at github.com>
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/85907
>From 66b7f2d14b941962ccba83662073afa41c6c08f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Wed, 20 Mar 2024 10:45:43 +0200
Subject: [PATCH 1/2] [libcxx] [modules] Fix relative paths with absolute
LIBCXX_INSTALL_MODULES_DIR (#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.
(cherry picked from commit 272d1b44efdedb68c194970a610f0ca1b7b769c5)
---
libcxx/modules/CMakeLists.txt | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 0dea8cfca94ac3..8dd1b51aac2f72 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -206,9 +206,15 @@ add_custom_target(generate-cxx-modules
# 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.
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
+ BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+ OUTPUT_VARIABLE ABS_LIBRARY_DIR)
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
+ BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+ OUTPUT_VARIABLE ABS_MODULES_DIR)
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"
>From 059dab03505d98d34e9d922fd76b3ce3b7b568a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Wed, 20 Mar 2024 17:48:48 +0200
Subject: [PATCH 2/2] [libcxx] [cmake] Fix cmake_path(ABSOLUTE_PATH) for empty
CMAKE_INSTALL_PREFIX
This should hopefully fix the issue brought up at
https://github.com/llvm/llvm-project/pull/85756#issuecomment-2009852291.
(cherry picked from commit d209d1340b99d4fbd325dffb5e13b757ab8264ea)
---
libcxx/modules/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 8dd1b51aac2f72..6c917200d6f318 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -207,10 +207,10 @@ add_custom_target(generate-cxx-modules
# Use the relative path between the installation and the module in the json
# file. This allows moving the entire installation to a different location.
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
- BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+ BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
OUTPUT_VARIABLE ABS_LIBRARY_DIR)
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
- BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+ BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
OUTPUT_VARIABLE ABS_MODULES_DIR)
file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
${ABS_LIBRARY_DIR}
More information about the llvm-branch-commits
mailing list