cmake: Allow CLANG_RESOURCE_DIR to be absolute.

Currently an absolute CLANG_RESOURCE_DIR is treated as being relative
to bin. Fix that by using cmake_path(APPEND) to append the path to bin.

The prepending of PREFIX is left as-is because callers passing PREFIX
are usually forming a path within the build directory and would not
want build products to be written to an absolute resource directory
that is likely to be an installation prefix. One exception is the caller
in lldb/cmake/modules/LLDBStandalone.cmake; for now it is not possible
to build LLDB with an absolute resource directory until the users are
disambiguated.

Reviewers: petrhosek

Reviewed By: petrhosek

Pull Request: https://github.com/llvm/llvm-project/pull/145996
This commit is contained in:
Peter Collingbourne
2025-06-27 16:04:35 -07:00
committed by GitHub
parent 5ecd21a46a
commit 71d4c9ce70

View File

@@ -10,7 +10,8 @@ function(get_clang_resource_dir out_var)
cmake_parse_arguments(ARG "" "PREFIX;SUBDIR" "" ${ARGN}) cmake_parse_arguments(ARG "" "PREFIX;SUBDIR" "" ${ARGN})
if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
set(ret_dir bin/${CLANG_RESOURCE_DIR}) set(ret_dir bin)
cmake_path(APPEND ret_dir ${CLANG_RESOURCE_DIR})
else() else()
if (NOT CLANG_VERSION_MAJOR) if (NOT CLANG_VERSION_MAJOR)
string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION}) string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION})