From fa5d416efdcbdba766c0c9bd0797bd4b8bbe0273 Mon Sep 17 00:00:00 2001 From: sameeran joshi Date: Mon, 22 Jun 2020 10:24:28 +0530 Subject: [PATCH] [flang]Fix individual tests with lit when building out of tree Summary: Fix individual check tests with lit when building out-of-tree `ninja check-flang-` was not working. The CMakeLists.txt was looking for the lit tests in the source directory instead of the build directory. This commit extends @CarolineConcatto previous patch[D81002] Reviewers: DavidTruby, sscalpone, tskeith, CarolineConcatto, jdoerfert Reviewed By: DavidTruby Subscribers: flang-commits, llvm-commits, CarolineConcatto Tags: #flang, #llvm Differential Revision: https://reviews.llvm.org/D82120 --- flang/CMakeLists.txt | 2 ++ flang/test/CMakeLists.txt | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index 5c4aad9bd65d..feb9544209bf 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -50,6 +50,7 @@ option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is trigger if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) message("Building Flang as a standalone project.") project(Flang) + set(FLANG_STANDALONE_BUILD ON) set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) if (NOT MSVC_IDE) @@ -179,6 +180,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() else() + set(FLANG_STANDALONE_BUILD OFF) option(FLANG_INCLUDE_TESTS "Generate build targets for the Flang unit tests." ${LLVM_INCLUDE_TESTS}) diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt index 6f47d67aa53e..ad47fff8c425 100644 --- a/flang/test/CMakeLists.txt +++ b/flang/test/CMakeLists.txt @@ -45,7 +45,13 @@ add_lit_testsuite(check-flang "Running the Flang regression tests" ) set_target_properties(check-flang PROPERTIES FOLDER "Tests") -add_lit_testsuites(FLANG ${CMAKE_CURRENT_SOURCE_DIR} - PARAMS ${FLANG_TEST_PARAMS} - DEPENDS ${FLANG_TEST_DEPENDS}) - +# In case of standalone builds. +if (FLANG_STANDALONE_BUILD) + add_lit_testsuites(FLANG ${CMAKE_CURRENT_BINARY_DIR} + PARAMS ${FLANG_TEST_PARAMS} + DEPENDS ${FLANG_TEST_DEPENDS}) +else() + add_lit_testsuites(FLANG ${CMAKE_CURRENT_SOURCE_DIR} + PARAMS ${FLANG_TEST_PARAMS} + DEPENDS ${FLANG_TEST_DEPENDS}) +endif()