[PATCH] D132608: [CMake] Clean up CMake binary dir handling

John Ericson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 24 14:21:14 PDT 2022


Ericson2314 created this revision.
Ericson2314 added reviewers: sebastian-ne, beanz, phosek, ldionne.
Herald added subscribers: libc-commits, libcxx-commits, Enna1, bzcheeseman, pmatos, asb, ayermolo, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, pengfei, jgravelle-google, whisperity, sbc100, mgorny, nemanjai, dschuff.
Herald added a reviewer: bollu.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: NoQ.
Herald added projects: libunwind, libc-project, Flang, All.
Herald added a reviewer: libunwind.
Ericson2314 requested review of this revision.
Herald added subscribers: llvm-commits, openmp-commits, lldb-commits, Sanitizers, cfe-commits, yota9, sstefan1, stephenneuendorffer, nicolasvasilache, jdoerfert, aheejin.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc++abi, MLIR, LLVM.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.

There are a few goals here:

- Match what D132316 <https://reviews.llvm.org/D132316> for `LLVM_BINARY_DIR`, for `CMAKE_BINARY_DIR`.

- Decrease the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586 <https://reviews.llvm.org/D130586>.

- Deduplicate code repeated across projects

Do this in this way:

- Shuffle around `CMAKE_MODULE_PATH` appending to allow `include`-ing our own modules earlier.

- Create new private/internal CMake modules and use them:
  - `GNUBinaryDirs`

    Like upstream CMake `GNUInstallDirs`, but sets variations of `CMAKE_BINARY_DIR`. These are not CACHE PATHS because they are not intended to be user-modifyable.

    `CMAKE_BINARY_LIBDIR` is based on the base name of `CMAKE_INSTALL_LIBDIR` rather than `LLVM_LIBDIR_SUFFIX`. This cannot just end with "lib", because the "install" and "binary" base names need to line up for various relative paths to work. It doesn't just use `LLVM_LIBDIR_SUFFIX` because we are trying to phase that out.
  - `LLVMLibdirSuffix`

    A compat shim that defaults `CMAKE_INSTALL_LIBDIR` based on `LLVM_LIBDIR_SUFFIX`.
  - `LLVMSetIntDirs`

    Just here to deduplicate the defining of `LLVM_LIBRARY_OUTPUT_INTDIR` and friends between projects.

- Do these replacements to make use of deps
  - `${CMAKE_BINARY_DIR}/lib(${CMAKE_LIBDIR_SUFFIX})?\>` -> `${CMAKE_BINARY_LIBDIR}`
  - `${CMAKE_BINARY_DIR}/bin\>` -> `${CMAKE_BINARY_BINDIR}`
  - `${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}` -> `${LLVM_LIBRARY_OUTPUT_INTDIR}`
  - `${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin` -> `${LLVM_RUNTIME_OUTPUT_INTDIR}`

    It is somewhat odd to me that those last two vars start with `LLVM_` not `CMAKE_` when they are based on `CMAKE_BINARY_DIR`, but that can be tackled some other time.

- Cleanup custom install path initialization code in the runtimes

  Most significantly, they no longer have their


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132608

Files:
  bolt/CMakeLists.txt
  bolt/tools/driver/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  cmake/Modules/GNUBinaryDirs.cmake
  cmake/Modules/LLVMLibdirSuffix.cmake
  cmake/Modules/LLVMSetIntDirs.cmake
  compiler-rt/CMakeLists.txt
  compiler-rt/cmake/base-config-ix.cmake
  flang/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  flang/tools/f18/CMakeLists.txt
  libc/CMakeLists.txt
  libc/test/utils/tools/WrapperGen/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  lld/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/bindings/python/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBStandalone.cmake
  llvm/CMakeLists.txt
  llvm/tools/llvm-go/CMakeLists.txt
  llvm/unittests/Target/AArch64/CMakeLists.txt
  llvm/unittests/Target/PowerPC/CMakeLists.txt
  llvm/unittests/Target/WebAssembly/CMakeLists.txt
  llvm/unittests/Target/X86/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  mlir/examples/standalone/CMakeLists.txt
  mlir/test/CMakeLists.txt
  mlir/utils/mbr/CMakeLists.txt
  openmp/CMakeLists.txt
  openmp/libomptarget/plugins/remote/CMakeLists.txt
  polly/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132608.455373.patch
Type: text/x-patch
Size: 53929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220824/8c185e21/attachment-0001.bin>


More information about the cfe-commits mailing list