From eb4aa6c7a5f22583e319aaaae3f6ee73cbc5464a Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 13 Jan 2023 20:26:02 +0100 Subject: [PATCH] [cmake] Fix path to LLVMConfig.cmake for multi-config builds D139623 replaces CMAKE_CFG_INTDIR with '.' for multi-config builds. However, this change has not been reflected in mlir, flang, polly, lld, and clang. The patch updates the path to LLVMConfig.cmake for those projects. Reviewed By: sebastian-ne Differential Revision: https://reviews.llvm.org/D141538 --- clang/cmake/modules/CMakeLists.txt | 3 ++- flang/cmake/modules/CMakeLists.txt | 3 ++- lld/cmake/modules/CMakeLists.txt | 3 ++- llvm/cmake/modules/AddLLVM.cmake | 2 +- llvm/cmake/modules/CMakeLists.txt | 2 +- mlir/cmake/modules/CMakeLists.txt | 3 ++- polly/cmake/CMakeLists.txt | 3 ++- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt index 749ef672c34f..d2d68121371b 100644 --- a/clang/cmake/modules/CMakeLists.txt +++ b/clang/cmake/modules/CMakeLists.txt @@ -15,7 +15,8 @@ set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/cla set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") +string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") +set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm") get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS) export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake) diff --git a/flang/cmake/modules/CMakeLists.txt b/flang/cmake/modules/CMakeLists.txt index 78cb1bc9cf99..4c0f9ab19cd8 100644 --- a/flang/cmake/modules/CMakeLists.txt +++ b/flang/cmake/modules/CMakeLists.txt @@ -14,7 +14,8 @@ set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/fla set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") +string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") +set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm") get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS) export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake) diff --git a/lld/cmake/modules/CMakeLists.txt b/lld/cmake/modules/CMakeLists.txt index e0578d7156a1..66db0354da65 100644 --- a/lld/cmake/modules/CMakeLists.txt +++ b/lld/cmake/modules/CMakeLists.txt @@ -14,7 +14,8 @@ set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/lld") set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") +string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") +set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm") get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS) export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 50e4d5d0681d..368f0d1c2a32 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1126,7 +1126,7 @@ function(process_llvm_pass_plugins) message(FATAL_ERROR "LLVM_INSTALL_PACKAGE_DIR must be defined and writable. GEN_CONFIG should only be passe when building LLVM proper.") endif() # LLVM_INSTALL_PACKAGE_DIR might be absolute, so don't reuse below. - string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") + string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm") file(WRITE "${llvm_cmake_builddir}/LLVMConfigExtensions.cmake" diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt index d2997a4706e1..d99af79aa38e 100644 --- a/llvm/cmake/modules/CMakeLists.txt +++ b/llvm/cmake/modules/CMakeLists.txt @@ -3,7 +3,7 @@ include(LLVMDistributionSupport) include(FindPrefixFromConfig) # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") +string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm") # First for users who use an installed LLVM, create the LLVMExports.cmake file. diff --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt index 3f15c2d5cd0b..254cfb6e05ca 100644 --- a/mlir/cmake/modules/CMakeLists.txt +++ b/mlir/cmake/modules/CMakeLists.txt @@ -15,7 +15,8 @@ set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") +string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") +set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm") get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS) export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MLIRTargets.cmake) diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt index d7b3fa1f29d8..b6181fbe4cc5 100644 --- a/polly/cmake/CMakeLists.txt +++ b/polly/cmake/CMakeLists.txt @@ -12,7 +12,8 @@ set(polly_cmake_builddir "${POLLY_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/pol set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") +string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}") +set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm") if (CMAKE_CONFIGURATION_TYPES) set(POLLY_EXPORTS_FILE_NAME "PollyExports-$>.cmake")