Index: cmake/modules/AddLLVM.cmake =================================================================== --- cmake/modules/AddLLVM.cmake +++ cmake/modules/AddLLVM.cmake @@ -1113,11 +1113,6 @@ # API for all shared libaries loaded by this executable. target_link_libraries(${test_name} PRIVATE gtest_main gtest ${LLVM_PTHREAD_LIB}) - set(LLVM_UNITTEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - configure_file( - ${LLVM_MAIN_SRC_DIR}/unittests/unittest.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/llvm.srcdir.txt) - add_dependencies(${test_suite} ${test_name}) get_target_property(test_suite_folder ${test_suite} FOLDER) if (NOT ${test_suite_folder} STREQUAL "NOTFOUND") @@ -1125,6 +1120,16 @@ endif () endfunction() +# Use for test binaries that call llvm::getInputFileDirectory(). Use of this +# is discouraged. +function(add_file_reading_unittest test_suite test_name) + set(LLVM_UNITTEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + configure_file( + ${LLVM_MAIN_SRC_DIR}/unittests/unittest.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/llvm.srcdir.txt) + + add_unittest(${test_suite} ${test_name} ${ARGN}) +endfunction() # Generic support for adding a benchmark. function(add_benchmark benchmark_name) Index: unittests/CMakeLists.txt =================================================================== --- unittests/CMakeLists.txt +++ unittests/CMakeLists.txt @@ -4,6 +4,9 @@ function(add_llvm_unittest test_dirname) add_unittest(UnitTests ${test_dirname} ${ARGN}) endfunction() +function(add_llvm_file_reading_unittest test_dirname) + add_file_reading_unittest(UnitTests ${test_dirname} ${ARGN}) +endfunction() add_subdirectory(ADT) add_subdirectory(Analysis) Index: unittests/DebugInfo/PDB/CMakeLists.txt =================================================================== --- unittests/DebugInfo/PDB/CMakeLists.txt +++ unittests/DebugInfo/PDB/CMakeLists.txt @@ -4,7 +4,7 @@ DebugInfoPDB ) -add_llvm_unittest(DebugInfoPDBTests +add_llvm_file_reading_unittest(DebugInfoPDBTests HashTableTest.cpp NativeSymbolReuseTest.cpp StringTableBuilderTest.cpp