[libc] Add path to include generated headers for hermetic tests
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 25 Apr 2023 23:29:35 +0000 (18:29 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 26 Apr 2023 21:52:29 +0000 (16:52 -0500)
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

index d905766..c5d403a 100644 (file)
@@ -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(