Skip to content

Commit 3e2a6d7

Browse files
committed
[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
1 parent 1a24bbe commit 3e2a6d7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,8 @@ function(process_llvm_pass_plugins)
11261126
message(FATAL_ERROR "LLVM_INSTALL_PACKAGE_DIR must be defined and writable. GEN_CONFIG should only be passe when building LLVM proper.")
11271127
endif()
11281128
# LLVM_INSTALL_PACKAGE_DIR might be absolute, so don't reuse below.
1129-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
1129+
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
1130+
set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
11301131
file(WRITE
11311132
"${llvm_cmake_builddir}/LLVMConfigExtensions.cmake"
11321133
"set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")

llvm/cmake/modules/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ include(LLVMDistributionSupport)
33
include(FindPrefixFromConfig)
44

55
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
6-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
6+
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
7+
set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
78

89
# First for users who use an installed LLVM, create the LLVMExports.cmake file.
910
set(LLVM_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMExports.cmake)

0 commit comments

Comments
 (0)