[RISCV] Add support for Smepmp 1.0 (#78489)
[llvm-project.git] / cmake / Modules / GNUInstallPackageDir.cmake
blobe4a058e68f4f42ff9e69a15a1dc39baeca269b1f
1 # Mimick `GNUInstallDirs` for one more install directory, the one where
2 # project's installed cmake subdirs go.
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.
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.
12 macro(_GNUInstallPackageDir_cache_convert_to_path var description)
13   get_property(_GNUInstallPackageDir_cache_type CACHE ${var} PROPERTY TYPE)
14   if(_GNUInstallPackageDir_cache_type STREQUAL "UNINITIALIZED")
15     file(TO_CMAKE_PATH "${${var}}" _GNUInstallPackageDir_cmakepath)
16     set_property(CACHE ${var} PROPERTY TYPE PATH)
17     set_property(CACHE ${var} PROPERTY VALUE "${_GNUInstallPackageDir_cmakepath}")
18     set_property(CACHE ${var} PROPERTY HELPSTRING "${description}")
19     unset(_GNUInstallPackageDir_cmakepath)
20   endif()
21   unset(_GNUInstallPackageDir_cache_type)
22 endmacro()
24 # Create a cache variable with default for a path.
25 macro(_GNUInstallPackageDir_cache_path var default description)
26   if(NOT DEFINED ${var})
27     set(${var} "${default}" CACHE PATH "${description}")
28   endif()
29   _GNUInstallPackageDir_cache_convert_to_path("${var}" "${description}")
30 endmacro()
32 _GNUInstallPackageDir_cache_path(CMAKE_INSTALL_PACKAGEDIR "lib${LLVM_LIBDIR_SUFFIX}/cmake"
33   "Directories containing installed CMake modules (lib/cmake)")