diff --git a/lldb/lit/CMakeLists.txt b/lldb/lit/CMakeLists.txt --- a/lldb/lit/CMakeLists.txt +++ b/lldb/lit/CMakeLists.txt @@ -1,6 +1,7 @@ # Test runner infrastructure for LLDB. This configures the LLDB test trees # for use by Lit, and delegates to LLVM's lit test handlers. +# LLVM_BUILD_MODE is used in lit.site.cfg if (CMAKE_CFG_INTDIR STREQUAL ".") set(LLVM_BUILD_MODE ".") else () @@ -12,10 +13,35 @@ endif() get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY) +set(dotest_args_replacement ${LLVM_BUILD_MODE}) +if(LLDB_BUILT_STANDALONE) + # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder. + string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}) + string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") + + # Remaining ones must be paths to the provided LLVM build-tree. + if(LLVM_CONFIGURATION_TYPES) + # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types. + # Otherwise, if both use multi-config the default is fine. + if(NOT CMAKE_CONFIGURATION_TYPES) + if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES) + set(dotest_args_replacement RelWithDebInfo) + elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES) + set(dotest_args_replacement Release) + else() + list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement) + endif() + endif() + else() + # Common case: LLVM used a single-configuration generator like Ninja. + set(dotest_args_replacement ".") + endif() +endif() + +string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") list(APPEND LLDB_TEST_DEPS LLDBUnitTests diff --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt --- a/lldb/utils/lldb-dotest/CMakeLists.txt +++ b/lldb/utils/lldb-dotest/CMakeLists.txt @@ -5,8 +5,28 @@ get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY) -# Generate wrapper for each build mode. -if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") +# Generate lldb-dotest Python driver script for each build mode. +if(LLDB_BUILT_STANDALONE) + foreach(config_type ${CMAKE_CONFIGURATION_TYPES}) + # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our actual configuration names. + string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}) + string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") + + # Remaining ones must be paths to the provided LLVM build-tree. + if(${config_type} IN_LIST LLVM_CONFIGURATION_TYPES) + # Multi-configuration generator like Xcode (with a matching config). + string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") + else() + # Single-configuration generator like Ninja. + string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") + endif() + + configure_file( + lldb-dotest.in + ${config_runtime_output_dir}/lldb-dotest @ONLY + ) + endforeach() +elseif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES}) string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")