llvm-project
29 строк · 854.0 Байт
1# get clang resource directory
2#
3# usage:
4# get_clang_resource_dir(out_var [PREFIX prefix] [SUBDIR subdirectory])
5#
6# user can use `PREFIX` to prepend some path to it or use `SUBDIR` to
7# get subdirectory under clang resource dir
8
9function(get_clang_resource_dir out_var)
10cmake_parse_arguments(ARG "" "PREFIX;SUBDIR" "" ${ARGN})
11
12if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
13set(ret_dir bin/${CLANG_RESOURCE_DIR})
14else()
15if (NOT CLANG_VERSION_MAJOR)
16string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION})
17endif()
18set(ret_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR})
19endif()
20
21if(ARG_PREFIX)
22set(ret_dir ${ARG_PREFIX}/${ret_dir})
23endif()
24if(ARG_SUBDIR)
25set(ret_dir ${ret_dir}/${ARG_SUBDIR})
26endif()
27
28set(${out_var} ${ret_dir} PARENT_SCOPE)
29endfunction()
30