[all-commits] [llvm/llvm-project] 3a1c81: [CMake] Avoid `LLVM_BINARY_DIR` when other more sp...

John Ericson via All-commits all-commits at lists.llvm.org
Wed Sep 14 12:49:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3a1c81e327391466f827cafef7156b164cb4c3e6
      https://github.com/llvm/llvm-project/commit/3a1c81e327391466f827cafef7156b164cb4c3e6
  Author: John Ericson <John.Ericson at Obsidian.Systems>
  Date:   2022-09-14 (Wed, 14 Sep 2022)

  Changed paths:
    M clang/cmake/modules/CMakeLists.txt
    M flang/cmake/modules/CMakeLists.txt
    M lld/cmake/modules/CMakeLists.txt
    M lldb/cmake/modules/LLDBConfig.cmake
    M llvm/CMakeLists.txt
    M llvm/cmake/modules/AddLLVM.cmake
    M llvm/cmake/modules/CMakeLists.txt
    M mlir/cmake/modules/CMakeLists.txt
    M polly/cmake/CMakeLists.txt
    M polly/test/CMakeLists.txt

  Log Message:
  -----------
  [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2

A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}\>` -> `${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `runtimes/CMakeLists.txt`

because these were "entry points" where we wanted to tread carefully not not introduce a "loop" which would end with an undefined variable being expanded to nothing.

There are some `${LLVM_BINARY_DIR}/lib` without the `${LLVM_LIBDIR_SUFFIX}`, but these refer to the lib subdirectory of the source (`llvm/lib`). That `lib` is automatically appended to make the local `CMAKE_CURRENT_BINARY_DIR` value by `add_subdirectory`; since the directory name in the source tree is fixed without any suffix, the corresponding `CMAKE_CURRENT_BINARY_DIR` will also be. We therefore do not replace it but leave it as-is.

This picks up where D133828 left off, getting the occurrences with*out* `CMAKE_CFG_INTDIR`. But this is difficult to do correctly and so not done in the (retroactively) previous diff.

This hopefully increases readability overall, and also decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

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




More information about the All-commits mailing list