diff options
| author | paperchalice <lgamma@163.com> | 2023-06-02 23:29:44 -0700 |
|---|---|---|
| committer | Tom Stellard <tstellar@redhat.com> | 2023-06-03 04:21:35 -0700 |
| commit | 0beffb854209a41f31beb18f9631258349a99299 (patch) | |
| tree | a2476605cbbdaae0b3f28ac6b46214c9b2578ae2 /cmake | |
| parent | 4c2ec08ebc62e70c872eb58f6adde77ed52c4cc9 (diff) | |
[CMake] Ensure `CLANG_RESOURCE_DIR` is respected.
re-commit of 39aa0f5c434b463520ac39a8dbe933ee8c4c5ea7 with missing file:
cmake/Modules/GetClangResourceDir.cmake.
Diffstat (limited to 'cmake')
| -rw-r--r-- | cmake/Modules/GetClangResourceDir.cmake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmake/Modules/GetClangResourceDir.cmake b/cmake/Modules/GetClangResourceDir.cmake new file mode 100644 index 000000000000..fb56e611a0e8 --- /dev/null +++ b/cmake/Modules/GetClangResourceDir.cmake @@ -0,0 +1,27 @@ +# get clang resource directory +# +# usage: +# get_clang_resource_dir(out_var [PREFIX prefix] [SUBDIR subdirectory]) +# +# user can use `PREFIX` to prepend some path to it or use `SUBDIR` to +# get subdirectory under clang resource dir + +function(get_clang_resource_dir out_var) + cmake_parse_arguments(ARG "" "PREFIX;SUBDIR" "" ${ARGN}) + + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") + set(ret_dir bin/${CLANG_RESOURCE_DIR}) + else() + string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION}) + set(ret_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}) + endif() + + if(ARG_PREFIX) + set(ret_dir ${ARG_PREFIX}/${ret_dir}) + endif() + if(ARG_SUBDIR) + set(ret_dir ${ret_dir}/${ARG_SUBDIR}) + endif() + + set(${out_var} ${ret_dir} PARENT_SCOPE) +endfunction() |
