diff --git a/clang-tools-extra/clangd/test/CMakeLists.txt b/clang-tools-extra/clangd/test/CMakeLists.txt --- a/clang-tools-extra/clangd/test/CMakeLists.txt +++ b/clang-tools-extra/clangd/test/CMakeLists.txt @@ -1,13 +1,3 @@ -# Set CLANG_TOOLS_DIR to buildtree/bin, or buildtree/%(build_mode)s/bin if the -# location is dynamic. The latter must be interpolated by lit configs. -# FIXME: this is duplicated in many places. -if (CMAKE_CFG_INTDIR STREQUAL ".") - set(LLVM_BUILD_MODE ".") -else () - set(LLVM_BUILD_MODE "%(build_mode)s") -endif () -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - set(CLANGD_TEST_DEPS clangd ClangdTests diff --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in b/clang-tools-extra/clangd/test/lit.site.cfg.py.in --- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in +++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in @@ -7,7 +7,7 @@ config.python_executable = "@Python3_EXECUTABLE@" # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. -config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@") +config.clang_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@") config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") diff --git a/clang-tools-extra/pseudo/test/CMakeLists.txt b/clang-tools-extra/pseudo/test/CMakeLists.txt --- a/clang-tools-extra/pseudo/test/CMakeLists.txt +++ b/clang-tools-extra/pseudo/test/CMakeLists.txt @@ -1,13 +1,3 @@ -# Set CLANG_TOOLS_DIR to buildtree/bin, or buildtree/%(build_mode)s/bin if the -# location is dynamic. The latter must be interpolated by lit configs. -# FIXME: this is duplicated in many places. -if (CMAKE_CFG_INTDIR STREQUAL ".") - set(LLVM_BUILD_MODE ".") -else () - set(LLVM_BUILD_MODE "%(build_mode)s") -endif () -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - set(CLANG_PSEUDO_TEST_DEPS clang-pseudo ClangPseudoTests diff --git a/clang-tools-extra/pseudo/test/lit.site.cfg.py.in b/clang-tools-extra/pseudo/test/lit.site.cfg.py.in --- a/clang-tools-extra/pseudo/test/lit.site.cfg.py.in +++ b/clang-tools-extra/pseudo/test/lit.site.cfg.py.in @@ -1,7 +1,7 @@ @LIT_SITE_CFG_IN_HEADER@ # Variables needed for common llvm config. -config.clang_tools_dir = "@CLANG_TOOLS_DIR@" +config.clang_tools_dir = "@CURRENT_TOOLS_DIR@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt --- a/clang-tools-extra/test/CMakeLists.txt +++ b/clang-tools-extra/test/CMakeLists.txt @@ -7,14 +7,6 @@ set(CLANG_TOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") set(CLANG_TOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") -if (CMAKE_CFG_INTDIR STREQUAL ".") - set(LLVM_BUILD_MODE ".") -else () - set(LLVM_BUILD_MODE "%(build_mode)s") -endif () - -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - llvm_canonicalize_cmake_booleans( CLANG_TIDY_ENABLE_STATIC_ANALYZER CLANG_PLUGIN_SUPPORT diff --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in --- a/clang-tools-extra/test/lit.site.cfg.py.in +++ b/clang-tools-extra/test/lit.site.cfg.py.in @@ -5,7 +5,6 @@ config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@" -config.clang_tools_dir = "@CLANG_TOOLS_DIR@" config.llvm_shlib_dir = "@SHLIBDIR@" config.python_executable = "@Python3_EXECUTABLE@" config.target_triple = "@LLVM_TARGET_TRIPLE@" @@ -16,7 +15,7 @@ # used when we can't determine the tool dir at configuration time. config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") -config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@") +config.clang_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@") import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -1,14 +1,6 @@ # Test runner infrastructure for Clang. This configures the Clang test trees # for use by Lit, and delegates to LLVM's lit test handlers. -if (CMAKE_CFG_INTDIR STREQUAL ".") - set(LLVM_BUILD_MODE ".") -else () - set(LLVM_BUILD_MODE "%(build_mode)s") -endif () - -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - llvm_canonicalize_cmake_booleans( CLANG_BUILD_EXAMPLES CLANG_DEFAULT_PIE_ON_LINUX @@ -39,7 +31,7 @@ "LLVM_EXTERNAL_LIT" "CLANG_BINARY_DIR" "CLANG_SOURCE_DIR" - "CLANG_TOOLS_DIR" + "CURRENT_TOOLS_DIR" "CMAKE_LIBRARY_OUTPUT_DIRECTORY" ) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -13,7 +13,7 @@ config.clang_lit_site_cfg = __file__ config.clang_obj_root = path(r"@CLANG_BINARY_DIR@") config.clang_src_dir = path(r"@CLANG_SOURCE_DIR@") -config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@") +config.clang_tools_dir = path(r"@CURRENT_TOOLS_DIR@") config.clang_lib_dir = path(r"@CMAKE_LIBRARY_OUTPUT_DIRECTORY@") config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@LLVM_TARGET_TRIPLE@" diff --git a/clang/utils/perf-training/CMakeLists.txt b/clang/utils/perf-training/CMakeLists.txt --- a/clang/utils/perf-training/CMakeLists.txt +++ b/clang/utils/perf-training/CMakeLists.txt @@ -1,11 +1,3 @@ -if (CMAKE_CFG_INTDIR STREQUAL ".") - set(LLVM_BUILD_MODE ".") -else () - set(LLVM_BUILD_MODE "%(build_mode)s") -endif () - -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "The path to a lit testsuite containing samples for PGO and order file generation" ) diff --git a/clang/utils/perf-training/lit.site.cfg.in b/clang/utils/perf-training/lit.site.cfg.in --- a/clang/utils/perf-training/lit.site.cfg.in +++ b/clang/utils/perf-training/lit.site.cfg.in @@ -2,7 +2,7 @@ import sys -config.clang_tools_dir = "@CLANG_TOOLS_DIR@" +config.clang_tools_dir = "@CURRENT_TOOLS_DIR@" config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@" config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@" config.test_source_root = "@CLANG_PGO_TRAINING_DATA@" diff --git a/clang/utils/perf-training/order-files.lit.site.cfg.in b/clang/utils/perf-training/order-files.lit.site.cfg.in --- a/clang/utils/perf-training/order-files.lit.site.cfg.in +++ b/clang/utils/perf-training/order-files.lit.site.cfg.in @@ -2,7 +2,7 @@ import sys -config.clang_tools_dir = "@CLANG_TOOLS_DIR@" +config.clang_tools_dir = "@CURRENT_TOOLS_DIR@" config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@" config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@" config.test_source_root = "@CLANG_PGO_TRAINING_DATA@" diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1630,13 +1630,15 @@ set_llvm_build_mode() - # The below might not be the build tree but provided binary tree. + # For standalone builds of subprojects, these might not be the build tree but + # a provided binary tree. set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR}) set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR}) string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}") string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}") - - # SHLIBDIR points the build tree. + # Like LLVM_{TOOLS,LIBS}_DIR, but pointing at the build tree. + string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" CURRENT_TOOLS_DIR "${LLVM_RUNTIME_OUTPUT_INTDIR}") + string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" CURRENT_LIBS_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}") string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}") # FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for