[PATCH] D132297: [bolt][llvm][cmake] Use `CMAKE_INSTALL_LIBDIR` too

John Ericson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 20 07:48:51 PDT 2022


Ericson2314 created this revision.
Herald added subscribers: ayermolo, mgorny.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
Ericson2314 requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Working back towards D130586 <https://reviews.llvm.org/D130586>.

Bolt didn't use `LLVM_LIBDIR_SUFFIX` before, and has no in-tree reverse
dependencies, it seems easier to add.

The change in LLVM itself is to prevent some unexpected `lib64` from
cropping up due to the `CMAKE_INSTALL_LIBDIR` defaulting logic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132297

Files:
  bolt/runtime/CMakeLists.txt
  llvm/CMakeLists.txt


Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -55,7 +55,15 @@
   VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}
   LANGUAGES C CXX ASM)
 
-# Must go after project(..)
+if (NOT DEFINED CMAKE_INSTALL_LIBDIR AND DEFINED LLVM_LIBDIR_SUFFIX)
+  # Must go before `include(GNUInstallDirs)`.
+  set(CMAKE_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+endif()
+
+# Must go after `DEFINED LLVM_LIBDIR_SUFFIX` check.
+set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
+
+# Must go after `project(..)`.
 include(GNUInstallDirs)
 
 # This C++ standard is required to build LLVM.
@@ -337,8 +345,6 @@
   message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
 endif()
 
-set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
-
 # LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools
 # subdirectory in order to have the value available for llvm-config.
 include(GNUInstallPackageDir)
Index: bolt/runtime/CMakeLists.txt
===================================================================
--- bolt/runtime/CMakeLists.txt
+++ bolt/runtime/CMakeLists.txt
@@ -1,5 +1,6 @@
 cmake_minimum_required(VERSION 3.13.4)
 include(CheckIncludeFiles)
+include(GNUInstallDirs)
 
 set(CMAKE_CXX_EXTENSIONS OFF)
 set(CMAKE_CXX_STANDARD 17)
@@ -32,8 +33,8 @@
 target_compile_options(bolt_rt_hugify PRIVATE ${BOLT_RT_FLAGS})
 target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 
-install(TARGETS bolt_rt_instr DESTINATION lib)
-install(TARGETS bolt_rt_hugify DESTINATION lib)
+install(TARGETS bolt_rt_instr DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+install(TARGETS bolt_rt_hugify DESTINATION "${CMAKE_INSTALL_LIBDIR}")
 
 if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*")
   add_library(bolt_rt_instr_osx STATIC
@@ -44,5 +45,5 @@
   target_compile_options(bolt_rt_instr_osx PRIVATE
     -target x86_64-apple-darwin19.6.0
     ${BOLT_RT_FLAGS})
-  install(TARGETS bolt_rt_instr_osx DESTINATION lib)
+  install(TARGETS bolt_rt_instr_osx DESTINATION "${CMAKE_INSTALL_LIBDIR}")
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132297.454213.patch
Type: text/x-patch
Size: 2216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220820/4d54c3b5/attachment.bin>


More information about the llvm-commits mailing list