Skip to content

Commit 232c77e

Browse files
committed
Revert "[CMake] Avoid LLVM_BINARY_DIR when other more specific variable are better-suited, part 2"
This reverts commit 3a1c81e. `CMAKE_CFG_INTDIR` expands to a *build* time reference to a per-configuration output subdirectory. It shouldn't be used at configuration time. This PR causes it to be much more widely used, breaking all but single-config Ninja generation. There's been some more work on this upstream, ie. https://reviews.llvm.org/D139623 and https://reviews.llvm.org/D141538 but it still isn't complete (ie. `CMAKE_CFG_INTDIR` is still being used).
1 parent ac6ccfa commit 232c77e

File tree

10 files changed

+12
-12
lines changed

10 files changed

+12
-12
lines changed

clang/cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/cla
1515
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
1616
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
1717
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
18-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
18+
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
1919

2020
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
2121
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)

flang/cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/fla
1414
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
1515
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
1616
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
17-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
17+
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
1818

1919
get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS)
2020
export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake)

lld/cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/lld")
1414
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
1515
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
1616
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
17-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
17+
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
1818

1919
get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS)
2020
export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ if (NOT TARGET clang-resource-headers)
338338
# could be and pick the first that exists.
339339
foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}"
340340
"${LLVM_BUILD_LIBRARY_DIR}"
341-
"${LLVM_LIBRARY_DIR}")
341+
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
342342
# Build the resource directory path by appending 'clang/<version number>'.
343343
set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}")
344344
if (IS_DIRECTORY "${CANDIDATE_RESOURCE_DIR}")

llvm/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -977,9 +977,9 @@ configure_file(
977977
)
978978

979979
# They are not referenced. See set_output_directory().
980-
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
981-
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} )
982-
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} )
980+
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin )
981+
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
982+
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
983983

984984
if(LLVM_INCLUDE_TESTS)
985985
include(GetErrcMessages)

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ function(process_llvm_pass_plugins)
11231123
message(FATAL_ERROR "LLVM_INSTALL_PACKAGE_DIR must be defined and writable. GEN_CONFIG should only be passe when building LLVM proper.")
11241124
endif()
11251125
# LLVM_INSTALL_PACKAGE_DIR might be absolute, so don't reuse below.
1126-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
1126+
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
11271127
file(WRITE
11281128
"${llvm_cmake_builddir}/LLVMConfigExtensions.cmake"
11291129
"set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")

llvm/cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ 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+
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
77

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

mlir/cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir
1515
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
1616
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
1717
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
18-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
18+
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
1919

2020
get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
2121
export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MLIRTargets.cmake)

polly/cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set(polly_cmake_builddir "${POLLY_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/pol
1212
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
1313
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
1414
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
15-
set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
15+
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
1616

1717
if (CMAKE_CONFIGURATION_TYPES)
1818
set(POLLY_EXPORTS_FILE_NAME "PollyExports-$<LOWER_CASE:$<CONFIG>>.cmake")

polly/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ endif ()
4646

4747
set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
4848
set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
49-
set(LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}")
49+
set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
5050
if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
5151
set(POLLY_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
5252
else()

0 commit comments

Comments
 (0)