From 50105d294241f2cd45b38c4304dda4f7df11abee Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 19 Sep 2017 17:19:10 +0000 Subject: [PATCH] Resubmit "Fix llvm-lit script generation in libcxx." After speaking with the libcxx owners, they agreed that this is a bug in the bot that needs to be fixed by the bot owners, and the CMake changes are correct. llvm-svn: 313643 --- libcxx/CMakeLists.txt | 10 ++++++++++ libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake | 5 +++++ libcxx/test/CMakeLists.txt | 5 ++--- llvm/cmake/modules/AddLLVM.cmake | 6 +++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index e402dae665ad..f2b7f83dd014 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -653,6 +653,7 @@ endif() # # However, since some submission systems strip test/ subdirectories, check for # it before adding it. + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test") add_subdirectory(test) endif() @@ -660,6 +661,15 @@ if (LIBCXX_INCLUDE_TESTS) add_subdirectory(lib/abi) endif() +if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit") + # Make sure the llvm-lit script is generated into the bin directory, and do + # it after adding all tests, since the generated script will only work + # correctly discovered tests against test locations from the source tree that + # have already been discovered. + add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit + ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit) +endif() + if (LIBCXX_INCLUDE_DOCS) add_subdirectory(docs) endif() diff --git a/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake b/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake index 879882dcfea6..b724bf69f1ae 100644 --- a/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake +++ b/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -106,6 +106,11 @@ macro(configure_out_of_tree_llvm) set(LLVM_ENABLE_SPHINX OFF) endif() + # In a standalone build, we don't have llvm to automatically generate the + # llvm-lit script for us. So we need to provide an explicit directory that + # the configurator should write the script into. + set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin") + # Required LIT Configuration ------------------------------------------------ # Define the default arguments to use with 'lit', and an option for the user # to override. diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt index 7b8a8322a11f..4c8ca8f6e55e 100644 --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -49,10 +49,9 @@ set(LIBCXX_EXECUTOR "None" CACHE STRING set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!") -configure_file( +configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - @ONLY) + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) set(LIBCXX_TEST_DEPS "") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 5cd20c684f85..06840fb9d74d 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1130,11 +1130,11 @@ function(configure_lit_site_cfg input output) # They below might not be the build tree but 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}) + 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. - string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}") + string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}") set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) # FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for