From f4d28d9e27dffca0388d4e7d87963ecc6d77d6e2 Mon Sep 17 00:00:00 2001 From: Cordell Bloor Date: Wed, 22 Mar 2023 16:48:10 -0600 Subject: HIP: Fix implicit include directory detection under /usr/include The `CMAKE__IMPLICIT_INCLUDE_DIRECTORIES` are computed using `try_compile` in `CMAKE_DETERMINE_COMPILER_ABI`, but the implicit include directories are not known during that `try_compile`. This can be a problem when the HIP runtime include path is `/usr/include`, because the runtime include path is always added to the userDirs and the compiler automatically includes standard library headers via `__clang_hip_runtime_wrapper.h`. Issue: #24562 --- Source/cmLocalGenerator.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 63b2043..7ad4023 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1201,6 +1201,17 @@ std::vector> cmLocalGenerator::GetIncludeDirectoriesImplicit( for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); } + + // The CMAKE__IMPLICIT_INCLUDE_DIRECTORIES are computed using + // try_compile in CMAKE_DETERMINE_COMPILER_ABI, but the implicit include + // directories are not known during that try_compile. This can be a + // problem when the HIP runtime include path is /usr/include because the + // runtime include path is always added to the userDirs and the compiler + // includes standard library headers via "__clang_hip_runtime_wrapper.h". + if (lang == "HIP" && impDirVec.size() == impDirVecOldSize && + !cm::contains(impDirVec, "/usr/include")) { + implicitExclude.emplace("/usr/include"); + } } // The Platform/UnixPaths module used to hard-code /usr/include for C, CXX, -- cgit v0.12