From fb5a3bc8f81ddbfbec5118eb1a881de8c7bdf615 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Tue, 25 Apr 2023 18:29:35 -0500 Subject: [PATCH] [libc] Add path to include generated headers for hermetic tests The generated header files live in the build directory's include path. When targeting a hermetic build we want to make sure we only use headers generated by the project itself if availible. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149216 --- libc/test/UnitTest/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt index d905766..c5d403a 100644 --- a/libc/test/UnitTest/CMakeLists.txt +++ b/libc/test/UnitTest/CMakeLists.txt @@ -27,6 +27,10 @@ add_library( foreach(lib LibcUnitTest LibcHermeticTest) target_include_directories(${lib} PUBLIC ${LIBC_SOURCE_DIR}) + if(LLVM_LIBC_FULL_BUILD) + # If we are in full build mode, then we should use our own public headers. + target_include_directories(${lib} PRIVATE ${LIBC_BUILD_DIR}/include) + endif() target_compile_options(${lib} PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} -fno-exceptions -fno-rtti) add_dependencies(${lib} @@ -48,6 +52,10 @@ add_library( target_include_directories(LibcTestMain PUBLIC ${LIBC_SOURCE_DIR}) target_compile_options(LibcTestMain PRIVATE -fno-exceptions -fno-rtti) +if(LLVM_LIBC_FULL_BUILD) + target_include_directories(LibcTestMain PRIVATE ${LIBC_BUILD_DIR}/include) + target_compile_options(LibcTestMain PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS}) +endif() add_dependencies(LibcTestMain LibcUnitTest) add_header_library( -- 2.7.4