[libcxx-commits] [libcxx] Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (PR #86020)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 21 04:52:50 PDT 2024


================
@@ -206,9 +206,18 @@ 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.
+#
+# Using a trailing slash in BASE_DIRECTORY, to produce a seemingly valid
+# absolute path, even if CMAKE_INSTALL_PREFIX is empty.
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
+  BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/"
----------------
mordante wrote:

I wonder what happens when `${CMAKE_INSTALL_PREFIX}` is "/", then we get "//". I'm not sure whether that is a valid path. How about something like
```
if(${CMAKE_INSTALL_PREFIX} STREQUAL "")
  set(BASE_DIRECTORY "/" PARENT_SCOPE)
else()
  set(BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX} PARENT_SCOPE)
endif()
```

https://github.com/llvm/llvm-project/pull/86020


More information about the libcxx-commits mailing list