[llvm] 3e2a6d7 - [llvm][cmake] Fix add_subdirectory build in multi-config

Sebastian Neubauer via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 02:57:33 PST 2022


Author: Sebastian Neubauer
Date: 2022-12-20T11:56:10+01:00
New Revision: 3e2a6d7f0317706ad5de93b26b51fda00e493c91

URL: https://github.com/llvm/llvm-project/commit/3e2a6d7f0317706ad5de93b26b51fda00e493c91
DIFF: https://github.com/llvm/llvm-project/commit/3e2a6d7f0317706ad5de93b26b51fda00e493c91.diff

LOG: [llvm][cmake] Fix add_subdirectory build in multi-config

Using CMAKE_CFG_INTDIR in paths that are used in configure_file,
resulted in a folder that is literally called '${CONFIGURATION}'
for the multi-config ninja build.

I think this is a regression from a while ago. Fix this by replacing
CMAKE_CFG_INTDIR with '.'. We can only create one of the
LLVMConfig.cmake files as the consuming CMake project can only import a
single file. This creates LLVMConfig.cmake and others in the place where
they were previously and where they are for a single-config build.

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

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake
    llvm/cmake/modules/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 376478e98b975..50e4d5d0681de 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1126,7 +1126,8 @@ 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.
-      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")
       file(WRITE
           "${llvm_cmake_builddir}/LLVMConfigExtensions.cmake"
           "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")

diff  --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt
index 428d8bff1cc66..e46b27a97ee64 100644
--- a/llvm/cmake/modules/CMakeLists.txt
+++ b/llvm/cmake/modules/CMakeLists.txt
@@ -3,7 +3,8 @@ include(LLVMDistributionSupport)
 include(FindPrefixFromConfig)
 
 # 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")
 
 # First for users who use an installed LLVM, create the LLVMExports.cmake file.
 set(LLVM_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMExports.cmake)


        


More information about the llvm-commits mailing list