[Openmp-commits] [openmp] 6fd2db0 - Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

John Ericson via Openmp-commits openmp-commits at lists.llvm.org
Tue Nov 2 07:23:39 PDT 2021


Author: John Ericson
Date: 2021-11-02T10:23:30-04:00
New Revision: 6fd2db04d0f22ea22c5317d98ce2126aa64b6a73

URL: https://github.com/llvm/llvm-project/commit/6fd2db04d0f22ea22c5317d98ce2126aa64b6a73
DIFF: https://github.com/llvm/llvm-project/commit/6fd2db04d0f22ea22c5317d98ce2126aa64b6a73.diff

LOG: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

This is a new draft of D28234. I previously did the unorthodox thing of
pushing to it when I wasn't the original author, but since this version

- Uses `GNUInstallDirs`, rather than mimics it, as the original author
  was hesitant to do but others requested.

- Is much broader, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I am using this patch (and many back-ports) as the basis of
https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It
looked like people were generally on board in D28234, but I make note of
this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM
already has some partial support for these sorts of things. For example
`LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not
quite clear yet what to do about those, we are holding off on changing
libdirs and `compiler-rt`. for this initial PR.

---

On the advice of @lebedev.ri, I am splitting this up a bit per
subproject, starting with LLVM. To allow it to be more easily reviewed. This and the subsequent patch must be landed together, as this will not build alone. But the rest can be landed on their own.

Reviewed By: compnerd

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

Added: 
    

Modified: 
    clang/tools/scan-build/CMakeLists.txt
    libclc/CMakeLists.txt
    lldb/cmake/modules/FindLibEdit.cmake
    llvm/CMakeLists.txt
    llvm/cmake/modules/AddLLVM.cmake
    llvm/cmake/modules/AddSphinxTarget.cmake
    llvm/cmake/modules/CMakeLists.txt
    llvm/cmake/modules/LLVMInstallSymlink.cmake
    llvm/docs/CMake.rst
    llvm/examples/Bye/CMakeLists.txt
    llvm/include/llvm/CMakeLists.txt
    llvm/tools/llvm-config/BuildVariables.inc.in
    llvm/tools/llvm-config/llvm-config.cpp
    llvm/tools/lto/CMakeLists.txt
    llvm/tools/opt-viewer/CMakeLists.txt
    llvm/tools/remarks-shlib/CMakeLists.txt
    openmp/runtime/src/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/tools/scan-build/CMakeLists.txt b/clang/tools/scan-build/CMakeLists.txt
index ec0702d76f184..74334e53c9b18 100644
--- a/clang/tools/scan-build/CMakeLists.txt
+++ b/clang/tools/scan-build/CMakeLists.txt
@@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD)
   endforeach()
 
   foreach(ManPage ${ManPages})
-    add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
+    add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}"
                        COMMAND ${CMAKE_COMMAND} -E make_directory
-                         ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
+                         "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1"
                        COMMAND ${CMAKE_COMMAND} -E copy
-                         ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
-                         ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
+                         "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}"
+                         "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/"
                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-    list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
+    list(APPEND Depends "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}")
     install(PROGRAMS man/${ManPage}
-            DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+            DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
             COMPONENT scan-build)
   endforeach()
 

diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index ec39ea63f2d02..e90e0fd852012 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -183,8 +183,8 @@ endif()
 
 # pkg-config file
 configure_file( libclc.pc.in libclc.pc @ONLY )
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig )
-install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" )
+install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" )
 
 if( ENABLE_RUNTIME_SUBNORMAL )
 	add_library( subnormal_use_default STATIC
@@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
 	add_library( subnormal_disable STATIC
 		generic/lib/subnormal_disable.ll )
 	install( TARGETS subnormal_use_default subnormal_disable ARCHIVE
-		DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+		DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
 endif()
 
 find_package( Python3 REQUIRED COMPONENTS Interpreter )
@@ -343,7 +343,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 			add_custom_target( "prepare-${spv_suffix}" ALL
 			                   DEPENDS "${spv_suffix}" )
 			install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix}
-				 DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+				 DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
 		else()
 
 			# Add prepare target
@@ -366,7 +366,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 					PROPERTIES ENVIRONMENT "LLVM_CONFIG=${LLVM_CONFIG}" )
 			endif()
 
-			install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+			install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
 			foreach( a ${${d}_aliases} )
 				set( alias_suffix "${a}-${t}.bc" )
 				add_custom_target( ${alias_suffix} ALL
@@ -374,7 +374,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 						   create_symlink ${obj_suffix}
 						   ${alias_suffix}
 				                   DEPENDS "prepare-${obj_suffix}" )
-				install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${alias_suffix} DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+				install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${alias_suffix} DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
 			endforeach( a )
 		endif()
 	endforeach( d )

diff  --git a/lldb/cmake/modules/FindLibEdit.cmake b/lldb/cmake/modules/FindLibEdit.cmake
index b4f0cb3298114..8b00d34de001a 100644
--- a/lldb/cmake/modules/FindLibEdit.cmake
+++ b/lldb/cmake/modules/FindLibEdit.cmake
@@ -25,14 +25,14 @@ else()
             HINTS
               ${PC_LIBEDIT_INCLUDEDIR}
               ${PC_LIBEDIT_INCLUDE_DIRS}
-              ${CMAKE_INSTALL_FULL_INCLUDEDIR})
+              "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
   find_library(LibEdit_LIBRARIES
                NAMES
                  edit libedit
                HINTS
                  ${PC_LIBEDIT_LIBDIR}
                  ${PC_LIBEDIT_LIBRARY_DIRS}
-                 ${CMAKE_INSTALL_FULL_LIBDIR})
+                 "${CMAKE_INSTALL_FULL_LIBDIR}")
 
   if(LibEdit_INCLUDE_DIRS AND EXISTS "${LibEdit_INCLUDE_DIRS}/histedit.h")
     file(STRINGS "${LibEdit_INCLUDE_DIRS}/histedit.h"

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index f07f29a5378b0..f4b03f4c82286 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -281,9 +281,12 @@ if (CMAKE_BUILD_TYPE AND
   message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
 endif()
 
+include(GNUInstallDirs)
+
 set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
 
-set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')")
+set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
+    "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
 mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)
 
 set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING
@@ -592,9 +595,9 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
 option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON)
 option (LLVM_ENABLE_BINDINGS "Build bindings." ON)
 
-set(LLVM_INSTALL_DOXYGEN_HTML_DIR "share/doc/llvm/doxygen-html"
+set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/doxygen-html"
     CACHE STRING "Doxygen-generated HTML documentation install directory")
-set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "share/doc/llvm/ocaml-html"
+set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/ocaml-html"
     CACHE STRING "OCamldoc-generated HTML documentation install directory")
 
 option (LLVM_BUILD_EXTERNAL_COMPILER_RT
@@ -1096,7 +1099,7 @@ endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
-    DESTINATION include
+    DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
     COMPONENT llvm-headers
     FILES_MATCHING
     PATTERN "*.def"
@@ -1107,7 +1110,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
     )
 
   install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c
-    DESTINATION include
+    DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
     COMPONENT llvm-headers
     FILES_MATCHING
     PATTERN "*.def"
@@ -1121,13 +1124,13 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 
   if (LLVM_INSTALL_MODULEMAPS)
     install(DIRECTORY include/llvm include/llvm-c
-            DESTINATION include
+            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
             COMPONENT llvm-headers
             FILES_MATCHING
             PATTERN "module.modulemap"
             )
     install(FILES include/llvm/module.install.modulemap
-            DESTINATION include/llvm
+            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm"
             COMPONENT llvm-headers
             RENAME "module.extern.modulemap"
             )

diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 695f8bef07dd6..3c4e9f69538c3 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -835,7 +835,7 @@ macro(add_llvm_library name)
               ${export_to_llvmexports}
               LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
               ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
-              RUNTIME DESTINATION bin COMPONENT ${name})
+              RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name})
 
       if (NOT LLVM_ENABLE_IDE)
         add_llvm_install_targets(install-${name}
@@ -1268,7 +1268,7 @@ macro(add_llvm_example name)
   endif()
   add_llvm_executable(${name} ${ARGN})
   if( LLVM_BUILD_EXAMPLES )
-    install(TARGETS ${name} RUNTIME DESTINATION examples)
+    install(TARGETS ${name} RUNTIME DESTINATION "${CMAKE_INSTALL_DOCDIR}/examples")
   endif()
   set_target_properties(${name} PROPERTIES FOLDER "Examples")
 endmacro(add_llvm_example name)

diff  --git a/llvm/cmake/modules/AddSphinxTarget.cmake b/llvm/cmake/modules/AddSphinxTarget.cmake
index e80c3b5c1cac9..256c9336e1f97 100644
--- a/llvm/cmake/modules/AddSphinxTarget.cmake
+++ b/llvm/cmake/modules/AddSphinxTarget.cmake
@@ -74,7 +74,7 @@ function (add_sphinx_target builder project)
     if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
       if (builder STREQUAL man)
         if (CMAKE_INSTALL_MANDIR)
-          set(INSTALL_MANDIR ${CMAKE_INSTALL_MANDIR}/)
+          set(INSTALL_MANDIR "${CMAKE_INSTALL_MANDIR}")
         else()
           set(INSTALL_MANDIR share/man/)
         endif()
@@ -90,7 +90,7 @@ function (add_sphinx_target builder project)
         endif()
       elseif (builder STREQUAL html)
         string(TOUPPER "${project}" project_upper)
-        set(${project_upper}_INSTALL_SPHINX_HTML_DIR "share/doc/${project}/html"
+        set(${project_upper}_INSTALL_SPHINX_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/html"
             CACHE STRING "HTML documentation install directory for ${project}")
 
         # '/.' indicates: copy the contents of the directory directly into

diff  --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt
index 51b6a4fdc2843..b2bb370124f2e 100644
--- a/llvm/cmake/modules/CMakeLists.txt
+++ b/llvm/cmake/modules/CMakeLists.txt
@@ -1,6 +1,7 @@
 include(LLVMDistributionSupport)
 
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm CACHE STRING
+  "Path for CMake subdirectory (defaults to 'lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm')")
 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
 
 # First for users who use an installed LLVM, create the LLVMExports.cmake file.
@@ -109,13 +110,13 @@ foreach(p ${_count})
   set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
 get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
 endforeach(p)
-set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
+set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
 set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
 set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
 set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
 set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
-set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
+set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
 
 # Generate a default location for lit
 if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)

diff  --git a/llvm/cmake/modules/LLVMInstallSymlink.cmake b/llvm/cmake/modules/LLVMInstallSymlink.cmake
index 3e6a2c9a26480..545883dd7dfb4 100644
--- a/llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ b/llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -4,7 +4,7 @@
 
 function(install_symlink name target outdir)
   set(DESTDIR $ENV{DESTDIR})
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
+  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
 
   message(STATUS "Creating ${name}")
 

diff  --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 72d303e60fda4..153c666041f46 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -252,6 +252,22 @@ manual, or execute ``cmake --help-variable VARIABLE_NAME``.
   Sets the C++ standard to conform to when building LLVM.  Possible values are
   14, 17, 20.  LLVM Requires C++ 14 or higher.  This defaults to 14.
 
+**CMAKE_INSTALL_BINDIR**:STRING
+  The path to install binary tools, relative to the ``CMAKE_INSTALL_PREFIX``.
+  Defaults to ``bin``.
+
+**CMAKE_INSTALL_INCLUDEDIR**:STRING
+  The path to install header files, relative to the ``CMAKE_INSTALL_PREFIX``.
+  Defaults to ``include``.
+
+**CMAKE_INSTALL_DOCDIR**:STRING
+  The path to install documentation, relative to the ``CMAKE_INSTALL_PREFIX``.
+  Defaults to ``share/doc``.
+
+**CMAKE_INSTALL_MANDIR**:STRING
+  The path to install manpage files, relative to the ``CMAKE_INSTALL_PREFIX``.
+  Defaults to ``share/man``.
+
 .. _LLVM-related variables:
 
 LLVM-related variables
@@ -592,12 +608,12 @@ enabled sub-projects. Nearly all of these variable names begin with
 **LLVM_INSTALL_OCAMLDOC_HTML_DIR**:STRING
   The path to install OCamldoc-generated HTML documentation to. This path can
   either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
-  `share/doc/llvm/ocaml-html`.
+  ``${CMAKE_INSTALL_DOCDIR}/llvm/ocaml-html``.
 
 **LLVM_INSTALL_SPHINX_HTML_DIR**:STRING
   The path to install Sphinx-generated HTML documentation to. This path can
   either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
-  `share/doc/llvm/html`.
+  ``${CMAKE_INSTALL_DOCDIR}/llvm/html``.
 
 **LLVM_INSTALL_UTILS**:BOOL
   If enabled, utility binaries like ``FileCheck`` and ``not`` will be installed
@@ -621,8 +637,8 @@ enabled sub-projects. Nearly all of these variable names begin with
 
 **LLVM_INSTALL_DOXYGEN_HTML_DIR**:STRING
   The path to install Doxygen-generated HTML documentation to. This path can
-  either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
-  `share/doc/llvm/doxygen-html`.
+  either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
+  ``${CMAKE_INSTALL_DOCDIR}/llvm/doxygen-html``.
 
 **LLVM_LINK_LLVM_DYLIB**:BOOL
   If enabled, tools will be linked with the libLLVM shared library. Defaults

diff  --git a/llvm/examples/Bye/CMakeLists.txt b/llvm/examples/Bye/CMakeLists.txt
index bb96edb4b4bf5..943c86143722e 100644
--- a/llvm/examples/Bye/CMakeLists.txt
+++ b/llvm/examples/Bye/CMakeLists.txt
@@ -14,6 +14,6 @@ if (NOT WIN32)
     BUILDTREE_ONLY
    )
 
-  install(TARGETS ${name} RUNTIME DESTINATION examples)
+  install(TARGETS ${name} RUNTIME DESTINATION "${CMAKE_INSTALL_DOCDIR}/examples")
   set_target_properties(${name} PROPERTIES FOLDER "Examples")
 endif()

diff  --git a/llvm/include/llvm/CMakeLists.txt b/llvm/include/llvm/CMakeLists.txt
index b46319f24fc8e..2feabd1954e40 100644
--- a/llvm/include/llvm/CMakeLists.txt
+++ b/llvm/include/llvm/CMakeLists.txt
@@ -5,5 +5,5 @@ add_subdirectory(Frontend)
 # If we're doing an out-of-tree build, copy a module map for generated
 # header files into the build area.
 if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
-  configure_file(module.modulemap.build module.modulemap COPYONLY)
+  configure_file(module.modulemap.build ${LLVM_INCLUDE_DIR}/module.modulemap COPYONLY)
 endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")

diff  --git a/llvm/tools/llvm-config/BuildVariables.inc.in b/llvm/tools/llvm-config/BuildVariables.inc.in
index ebe5b73a5c658..e2c0fca6db9a7 100644
--- a/llvm/tools/llvm-config/BuildVariables.inc.in
+++ b/llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,8 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"

diff  --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
index 8afd3593272f5..bce73aeabd815 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@ int main(int argc, char **argv) {
         ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
     ActivePrefix = CurrentExecPrefix;
-    ActiveIncludeDir = ActivePrefix + "/include";
-    SmallString<256> path(LLVM_TOOLS_INSTALL_DIR);
-    sys::fs::make_absolute(ActivePrefix, path);
-    ActiveBinDir = std::string(path.str());
+    {
+      SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
+      sys::fs::make_absolute(ActivePrefix, Path);
+      ActiveIncludeDir = std::string(Path.str());
+    }
+    {
+      SmallString<256> Path(LLVM_INSTALL_BINDIR);
+      sys::fs::make_absolute(ActivePrefix, Path);
+      ActiveBinDir = std::string(Path.str());
+    }
     ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
     ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
     ActiveIncludeOption = "-I" + ActiveIncludeDir;

diff  --git a/llvm/tools/lto/CMakeLists.txt b/llvm/tools/lto/CMakeLists.txt
index 0af29ad762c55..67f6d3af40e05 100644
--- a/llvm/tools/lto/CMakeLists.txt
+++ b/llvm/tools/lto/CMakeLists.txt
@@ -33,7 +33,7 @@ add_llvm_library(${LTO_LIBRARY_NAME} ${LTO_LIBRARY_TYPE} INSTALL_WITH_TOOLCHAIN
     ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)

diff  --git a/llvm/tools/opt-viewer/CMakeLists.txt b/llvm/tools/opt-viewer/CMakeLists.txt
index ead73ec13a8f5..c0070f8cbfac8 100644
--- a/llvm/tools/opt-viewer/CMakeLists.txt
+++ b/llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@ set (files
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-    DESTINATION share/opt-viewer
+    DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
     COMPONENT opt-viewer)
 endforeach (file)
 

diff  --git a/llvm/tools/remarks-shlib/CMakeLists.txt b/llvm/tools/remarks-shlib/CMakeLists.txt
index 8654362472700..f22cedd9ead78 100644
--- a/llvm/tools/remarks-shlib/CMakeLists.txt
+++ b/llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@ if(LLVM_ENABLE_PIC)
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-    DESTINATION include/llvm-c
+    DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
     COMPONENT Remarks)
 
   if (APPLE)

diff  --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index bdb867e352f78..d0bd678d7c13f 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -323,7 +323,7 @@ if(WIN32)
     install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
       \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/bin)")
     install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
-      \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+      \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
   endforeach()
 else()
 
@@ -335,7 +335,7 @@ else()
     foreach(alias IN LISTS LIBOMP_ALIASES)
       install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
         \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
-        \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+        \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
     endforeach()
   endif()
 endif()


        


More information about the Openmp-commits mailing list