[llvm] 5f7afa9 - Simplify AddSphinxTarget.cmake by just including `GNUInstallDirs`

John Ericson via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 13 13:27:43 PST 2021


Author: John Ericson
Date: 2021-12-13T21:27:39Z
New Revision: 5f7afa96071c7fffb44c253a63c1c552f98a9c79

URL: https://github.com/llvm/llvm-project/commit/5f7afa96071c7fffb44c253a63c1c552f98a9c79
DIFF: https://github.com/llvm/llvm-project/commit/5f7afa96071c7fffb44c253a63c1c552f98a9c79.diff

LOG: Simplify AddSphinxTarget.cmake by just including `GNUInstallDirs`

See the discussion in D30906 for how it must be robust to downstream
projects that might not use `GNUInstallDirs`.

I think an easier approach is just to include `GNUInstallDirs` so that
we can always rely on it. Looking at its definition in
https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/GNUInstallDirs.cmake
it appears safe to include multiple times.

I am trying this out because we will face the same problem many times
over if we use `GNUInstallDirs` more widely, as proposed in D99484 and
its parent revisions, since we do not know what downstream projects do
and rather not break them.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D115601

Added: 
    

Modified: 
    llvm/cmake/modules/AddSphinxTarget.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddSphinxTarget.cmake b/llvm/cmake/modules/AddSphinxTarget.cmake
index d14095d3aa74d..fb8b6d95d9ff7 100644
--- a/llvm/cmake/modules/AddSphinxTarget.cmake
+++ b/llvm/cmake/modules/AddSphinxTarget.cmake
@@ -1,3 +1,4 @@
+include(GNUInstallDirs)
 
 # Create sphinx target
 if (LLVM_ENABLE_SPHINX)
@@ -73,15 +74,10 @@ function (add_sphinx_target builder project)
     # Handle installation
     if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
       if (builder STREQUAL man)
-        if (CMAKE_INSTALL_MANDIR)
-          set(INSTALL_MANDIR "${CMAKE_INSTALL_MANDIR}/")
-        else()
-          set(INSTALL_MANDIR share/man/)
-        endif()
         # FIXME: We might not ship all the tools that these man pages describe
         install(DIRECTORY "${SPHINX_BUILD_DIR}/" # Slash indicates contents of
                 COMPONENT "${project}-sphinx-man"
-                DESTINATION ${INSTALL_MANDIR}man1)
+                DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
 
         if(NOT LLVM_ENABLE_IDE)
           add_llvm_install_targets("install-${SPHINX_TARGET_NAME}"


        


More information about the llvm-commits mailing list