llvm-project
33 строки · 1.5 Кб
1# Mimick `GNUInstallDirs` for one more install directory, the one where
2# project's installed cmake subdirs go.
3
4# These functions are internal functions vendored in from GNUInstallDirs (with
5# new names), so we don't depend on unstable implementation details. They are
6# also simplified to only handle the cases we need.
7#
8# The purpose would appear to be making `CACHE PATH` vars in a way that
9# bypasses the legacy oddity that `-D<PATH>` gets canonicalized, despite
10# non-canonical `CACHE PATH`s being perfectly valid.
11
12macro(_GNUInstallPackageDir_cache_convert_to_path var description)
13get_property(_GNUInstallPackageDir_cache_type CACHE ${var} PROPERTY TYPE)
14if(_GNUInstallPackageDir_cache_type STREQUAL "UNINITIALIZED")
15file(TO_CMAKE_PATH "${${var}}" _GNUInstallPackageDir_cmakepath)
16set_property(CACHE ${var} PROPERTY TYPE PATH)
17set_property(CACHE ${var} PROPERTY VALUE "${_GNUInstallPackageDir_cmakepath}")
18set_property(CACHE ${var} PROPERTY HELPSTRING "${description}")
19unset(_GNUInstallPackageDir_cmakepath)
20endif()
21unset(_GNUInstallPackageDir_cache_type)
22endmacro()
23
24# Create a cache variable with default for a path.
25macro(_GNUInstallPackageDir_cache_path var default description)
26if(NOT DEFINED ${var})
27set(${var} "${default}" CACHE PATH "${description}")
28endif()
29_GNUInstallPackageDir_cache_convert_to_path("${var}" "${description}")
30endmacro()
31
32_GNUInstallPackageDir_cache_path(CMAKE_INSTALL_PACKAGEDIR "lib${LLVM_LIBDIR_SUFFIX}/cmake"
33"Directories containing installed CMake modules (lib/cmake)")
34