cmake_path.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. cmake_path
  2. ----------
  3. .. versionadded:: 3.19
  4. Filesystem path manipulation command.
  5. This command is dedicated to the manipulation of objects of type path which
  6. represent paths on a filesystem. Only syntactic aspects of paths are handled:
  7. the pathname may represent a non-existing path or even one that is not allowed
  8. to exist on the current file system or OS.
  9. For operations involving the filesystem, have a look at the :command:`file`
  10. command.
  11. The path name has the following syntax:
  12. 1. ``root-name`` (optional): identifies the root on a filesystem with multiple
  13. roots (such as ``"C:"`` or ``"//myserver"``).
  14. 2. ``root-directory`` (optional): a directory separator that, if present, marks
  15. this path as absolute. If it is missing (and the first element other than
  16. the root name is a file name), then the path is relative.
  17. Zero or more of the following:
  18. 3. ``file-name``: sequence of characters that aren't directory separators. This
  19. name may identify a file, a hard link, a symbolic link, or a directory. Two
  20. special file-names are recognized:
  21. * ``dot``: the file name consisting of a single dot character ``.`` is a
  22. directory name that refers to the current directory.
  23. * ``dot-dot``: the file name consisting of two dot characters ``..`` is a
  24. directory name that refers to the parent directory.
  25. 4. ``directory-separator``: the forward slash character ``/``. If this
  26. character is repeated, it is treated as a single directory separator:
  27. ``/usr///////lib`` is the same as ``/usr/lib``.
  28. .. _EXTENSION_DEF:
  29. A ``file-name`` can have an extension. By default, the extension is defined as
  30. the sub-string beginning at the leftmost period (including the period) and
  31. until the end of the pathname. When the option ``LAST_ONLY`` is specified, the
  32. extension is the sub-string beginning at the rightmost period.
  33. .. note::
  34. ``cmake_path`` command handles paths in the format of the build system, not
  35. the target system. So this is not generally applicable to the target system
  36. in cross-compiling environment.
  37. For all commands, ``<path>`` placeholder expect a variable name. An error will
  38. be raised if the variable does not exist, except for `APPEND`_ and
  39. `CMAKE_PATH`_ sub-commands. ``<input>`` placeholder expect a string literal.
  40. ``[<input>...]`` placeholder expect zero or more arguments. ``<output>``
  41. placeholder expect a variable name.
  42. .. note::
  43. ``cmake_path`` command does not support list of paths. The ``<path>``
  44. placeholder must store only one path name.
  45. To initialize a path variable, three possibilities can be used:
  46. 1. :command:`set` command.
  47. 2. :ref:`cmake_path(APPEND) <APPEND>` command. Can be used to build a path from
  48. already available path fragments.
  49. 3. :ref:`cmake_path(CMAKE_PATH) <CMAKE_PATH>` command. Mainly used to build a
  50. path variable from a native path.
  51. .. code-block:: cmake
  52. # To build the path "${CMAKE_CURRENT_SOURCE_DIR}/data"
  53. set (path1 "${CMAKE_CURRENT_SOURCE_DIR}/data")
  54. cmake_path(APPEND path2 "${CMAKE_CURRENT_SOURCE_DIR}" "data")
  55. cmake_path(CMAKE_PATH path3 "${CMAKE_CURRENT_SOURCE_DIR}/data")
  56. `Modification`_ and `Generation`_ sub-commands store the result in-place or in
  57. the variable specified by ``OUTPUT_VARIABLE`` option. All other sub-commands,
  58. except `CMAKE_PATH`_, store the result in the required ``<output>`` variable.
  59. Sub-commands supporting ``NORMALIZE`` option will :ref:`normalize <NORMAL_PATH>`
  60. the path.
  61. Synopsis
  62. ^^^^^^^^
  63. .. parsed-literal::
  64. `Decomposition`_
  65. cmake_path(`GET`_ <path> :ref:`ROOT_NAME <GET_ROOT_NAME>` <output>)
  66. cmake_path(`GET`_ <path> :ref:`ROOT_DIRECTORY <GET_ROOT_DIRECTORY>` <output>)
  67. cmake_path(`GET`_ <path> :ref:`ROOT_PATH <GET_ROOT_PATH>` <output>)
  68. cmake_path(`GET`_ <path> :ref:`FILENAME <GET_FILENAME>` <output>)
  69. cmake_path(`GET`_ <path> :ref:`EXTENSION <GET_EXTENSION>` [LAST_ONLY] <output>)
  70. cmake_path(`GET`_ <path> :ref:`STEM <GET_STEM>` [LAST_ONLY] <output>)
  71. cmake_path(`GET`_ <path> :ref:`RELATIVE_PATH <GET_RELATIVE_PATH>` <output>)
  72. cmake_path(`GET`_ <path> :ref:`PARENT_PATH <GET_PARENT_PATH>` <output>)
  73. `Modification`_
  74. cmake_path(`APPEND`_ <path> [<input>...] [OUTPUT_VARIABLE <output>])
  75. cmake_path(`CONCAT`_ <path> [<input>...] [OUTPUT_VARIABLE <output>])
  76. cmake_path(`REMOVE_FILENAME`_ <path> [OUTPUT_VARIABLE <output>])
  77. cmake_path(`REPLACE_FILENAME`_ <path> <input> [OUTPUT_VARIABLE <output>])
  78. cmake_path(`REMOVE_EXTENSION`_ <path> [LAST_ONLY]
  79. [OUTPUT_VARIABLE <output>])
  80. cmake_path(`REPLACE_EXTENSION`_ <path> [LAST_ONLY] <input>
  81. [OUTPUT_VARIABLE <output>])
  82. `Generation`_
  83. cmake_path(`NORMAL_PATH`_ <path> [OUTPUT_VARIABLE <output>])
  84. cmake_path(`RELATIVE_PATH`_ <path> [BASE_DIRECTORY <path>]
  85. [OUTPUT_VARIABLE <output>])
  86. cmake_path(`PROXIMATE_PATH`_ <path> [BASE_DIRECTORY <path>]
  87. [OUTPUT_VARIABLE <output>])
  88. cmake_path(`ABSOLUTE_PATH`_ <path> [BASE_DIRECTORY <path>] [NORMALIZE]
  89. [OUTPUT_VARIABLE <output>])
  90. `Conversion`_
  91. cmake_path(`CMAKE_PATH`_ <path> [NORMALIZE] <input>)
  92. cmake_path(`NATIVE_PATH`_ <path> [NORMALIZE] <output>)
  93. cmake_path(`CONVERT`_ <input> `TO_CMAKE_PATH_LIST`_ <output>)
  94. cmake_path(`CONVERT`_ <input> `TO_NATIVE_PATH_LIST`_ <output>)
  95. `Comparison`_
  96. cmake_path(`COMPARE`_ <path> <OP> <input> <output>)
  97. `Query`_
  98. cmake_path(`HAS_ROOT_NAME`_ <path> <output>)
  99. cmake_path(`HAS_ROOT_DIRECTORY`_ <path> <output>)
  100. cmake_path(`HAS_ROOT_PATH`_ <path> <output>)
  101. cmake_path(`HAS_FILENAME`_ <path> <output>)
  102. cmake_path(`HAS_EXTENSION`_ <path> <output>)
  103. cmake_path(`HAS_STEM`_ <path> <output>)
  104. cmake_path(`HAS_RELATIVE_PATH`_ <path> <output>)
  105. cmake_path(`HAS_PARENT_PATH`_ <path> <output>)
  106. cmake_path(`IS_ABSOLUTE`_ <path> <output>)
  107. cmake_path(`IS_RELATIVE`_ <path> <output>)
  108. cmake_path(`IS_PREFIX`_ <path> <input> [NORMALIZE] <output>)
  109. `Hashing`_
  110. cmake_path(`HASH`_ <path> [NORMALIZE] <output>)
  111. Decomposition
  112. ^^^^^^^^^^^^^
  113. .. _GET:
  114. .. _GET_ROOT_NAME:
  115. .. code-block:: cmake
  116. cmake_path(GET <path> ROOT_NAME <output>)
  117. Returns the root name of the path. If the path does not include a root name,
  118. returns an empty path.
  119. .. _GET_ROOT_DIRECTORY:
  120. .. code-block:: cmake
  121. cmake_path(GET <path> ROOT_DIRECTORY <output>)
  122. Returns the root directory of the path. If the path does not include a root
  123. directory, returns an empty path.
  124. .. _GET_ROOT_PATH:
  125. .. code-block:: cmake
  126. cmake_path(GET <path> ROOT_PATH <output>)
  127. Returns the root path of the path. If the path does not include a root path,
  128. returns an empty path.
  129. Effectively, returns the following: ``root-name / root-directory``.
  130. .. _GET_FILENAME:
  131. .. code-block:: cmake
  132. cmake_path(GET <path> FILENAME <output>)
  133. Returns the filename component of the path. If the path ends with a
  134. ``directory-separator``, there is no filename, so returns an empty path.
  135. .. _GET_EXTENSION:
  136. .. code-block:: cmake
  137. cmake_path(GET <path> EXTENSION [LAST_ONLY] <output>)
  138. Returns the :ref:`extension <EXTENSION_DEF>` of the filename component.
  139. If the ``FILENAME`` component of the path contains a period (``.``), and is not
  140. one of the special filesystem elements ``dot`` or ``dot-dot``, then the
  141. :ref:`extension <EXTENSION_DEF>` is returned.
  142. .. code-block:: cmake
  143. set (path "name.ext1.ext2")
  144. cmake_path (GET path EXTENSION result)
  145. cmake_path (GET path EXTENSION LAST_ONLY result)
  146. First extension extraction will return ``.ex1.ext2``, while the second one will
  147. return only ``.ext2``.
  148. The following exceptions apply:
  149. * If the first character in the filename is a period, that period is ignored
  150. (a filename like ``".profile"`` is not treated as an extension).
  151. * If the pathname is either ``.`` or ``..``, or if ``FILENAME`` component
  152. does not contain the ``.`` character, then an empty path is returned.
  153. .. _GET_STEM:
  154. .. code-block:: cmake
  155. cmake_path(GET <path> STEM [LAST_ONLY] <output>)
  156. Returns the ``FILENAME`` component of the path stripped of its
  157. :ref:`extension <EXTENSION_DEF>`.
  158. .. code-block:: cmake
  159. set (path "name.ext1.ext2")
  160. cmake_path (GET path STEM result)
  161. cmake_path (GET path STEM LAST_ONLY result)
  162. First stem extraction will return only ``name``, while the second one will
  163. return ``name.ext1``.
  164. The following exceptions apply:
  165. * If the first character in the filename is a period, that period is ignored
  166. (a filename like ``".profile"`` is not treated as an extension).
  167. * If the filename is one of the special filesystem components ``dot`` or
  168. ``dot-dot``, or if it has no periods, the function returns the entire
  169. ``FILENAME`` component.
  170. .. _GET_RELATIVE_PATH:
  171. .. code-block:: cmake
  172. cmake_path(GET <path> RELATIVE_PATH <output>)
  173. Returns path relative to ``root-path``, that is, a pathname composed of
  174. every component of ``<path>`` after ``root-path``. If ``<path>`` is an empty
  175. path, returns an empty path.
  176. .. _GET_PARENT_PATH:
  177. .. code-block:: cmake
  178. cmake_path(GET <path> PARENT_PATH <output>)
  179. Returns the path to the parent directory.
  180. If `HAS_RELATIVE_PATH`_ sub-command returns false, the result is a copy of
  181. ``<path>``. Otherwise, the result is ``<path>`` with one fewer element.
  182. Modification
  183. ^^^^^^^^^^^^
  184. .. _APPEND:
  185. .. code-block:: cmake
  186. cmake_path(APPEND <path> [<input>...] [OUTPUT_VARIABLE <output>])
  187. Append all the ``<input>`` arguments to the ``<path>`` using ``/`` as
  188. ``directory-separator``.
  189. For each ``<input>`` argument, the following algorithm (pseudo-code) applies:
  190. .. code-block:: cmake
  191. IF (<input>.is_absolute() OR
  192. (<input>.has_root_name() AND
  193. NOT <input>.root_name() STREQUAL <path>.root_name()))
  194. replaces <path> with <input>
  195. RETURN()
  196. ENDIF()
  197. IF (<input>.has_root_directory())
  198. remove any root-directory and the entire relative path from <path>
  199. ELSEIF (<path>.has_filename() OR
  200. (NOT <path>.has_root_directory() OR <path>.is_absolute()))
  201. appends directory-separator to <path>
  202. ENDIF()
  203. appends <input> omitting any root-name to <path>
  204. .. _CONCAT:
  205. .. code-block:: cmake
  206. cmake_path(CONCAT <path> [<input>...] [OUTPUT_VARIABLE <output>])
  207. Concatenates all the ``<input>`` arguments to the ``<path>`` without
  208. ``directory-separator``.
  209. .. _REMOVE_FILENAME:
  210. .. code-block:: cmake
  211. cmake_path(REMOVE_FILENAME <path> [OUTPUT_VARIABLE <output>])
  212. Removes a single filename component (as returned by
  213. :ref:`GET ... FILENAME <GET_FILENAME>`) from ``<path>``.
  214. After this function returns, if change is done in-place, `HAS_FILENAME`_
  215. returns false for ``<path>``.
  216. .. _REPLACE_FILENAME:
  217. .. code-block:: cmake
  218. cmake_path(REPLACE_FILENAME <path> <input> [OUTPUT_VARIABLE <output>])
  219. Replaces a single filename component from ``<path>`` with ``<input>``.
  220. Equivalent to the following:
  221. .. code-block:: cmake
  222. cmake_path(REMOVE_FILENAME path)
  223. cmake_path(APPEND path "replacement");
  224. If ``<path>`` has no filename component (`HAS_FILENAME`_ returns false), the
  225. path is unchanged.
  226. .. _REMOVE_EXTENSION:
  227. .. code-block:: cmake
  228. cmake_path(REMOVE_EXTENSION <path> [LAST_ONLY] [OUTPUT_VARIABLE <output>])
  229. Removes the :ref:`extension <EXTENSION_DEF>`, if any, from ``<path>``.
  230. .. _REPLACE_EXTENSION:
  231. .. code-block:: cmake
  232. cmake_path(REPLACE_EXTENSION <path> [LAST_ONLY] <input>
  233. [OUTPUT_VARIABLE <output>])
  234. Replaces the :ref:`extension <EXTENSION_DEF>` with ``<input>``.
  235. First, if ``<path>`` has an :ref:`extension <EXTENSION_DEF>` (`HAS_EXTENSION`_
  236. is true), it is removed. Then, a ``dot`` character is appended to ``<path>``,
  237. if ``<input>`` is not empty or does not begin with a ``dot`` character.
  238. Then ``<input>`` is appended as if `CONCAT`_ was used.
  239. Generation
  240. ^^^^^^^^^^
  241. .. _NORMAL_PATH:
  242. .. code-block:: cmake
  243. cmake_path(NORMAL_PATH <path> [OUTPUT_VARIABLE <output>])
  244. Normalize ``<path>``.
  245. A path can be normalized by following this algorithm:
  246. 1. If the path is empty, stop (normal form of an empty path is an empty
  247. path).
  248. 2. Replace each ``directory-separator`` (which may consist of multiple
  249. separators) with a single ``/``.
  250. 3. Replace each ``directory-separator`` character in the ``root-name`` with
  251. ``/``.
  252. 4. Remove each ``dot`` and any immediately following ``directory-separator``.
  253. 5. Remove each non-dot-dot filename immediately followed by a
  254. ``directory-separator`` and a ``dot-dot``, along with any immediately
  255. following ``directory-separator``.
  256. 6. If there is ``root-directory``, remove all ``dot-dots`` and any
  257. ``directory-separators`` immediately following them.
  258. 7. If the last filename is ``dot-dot``, remove any trailing
  259. ``directory-separator``.
  260. 8. If the path is empty, add a ``dot`` (normal form of ``./`` is ``.``).
  261. .. _cmake_path-RELATIVE_PATH:
  262. .. _RELATIVE_PATH:
  263. .. code-block:: cmake
  264. cmake_path(RELATIVE_PATH <path> [BASE_DIRECTORY <path>]
  265. [OUTPUT_VARIABLE <output>])
  266. Returns ``<path>`` made relative to ``BASE_DIRECTORY`` argument. If
  267. ``BASE_DIRECTORY`` is not specified, the default base directory will be
  268. :variable:`CMAKE_CURRENT_SOURCE_DIR`.
  269. For reference, the algorithm used to compute the relative path is described
  270. `here <https://en.cppreference.com/w/cpp/filesystem/path/lexically_normal>`_.
  271. .. _PROXIMATE_PATH:
  272. .. code-block:: cmake
  273. cmake_path(PROXIMATE_PATH <path> [BASE_DIRECTORY <path>]
  274. [OUTPUT_VARIABLE <output>])
  275. If the value of `RELATIVE_PATH`_ is not an empty path, return
  276. it. Otherwise return ``<path>``.
  277. If ``BASE_DIRECTORY`` is not specified, the default base directory will be
  278. :variable:`CMAKE_CURRENT_SOURCE_DIR`.
  279. .. _ABSOLUTE_PATH:
  280. .. code-block:: cmake
  281. cmake_path(ABSOLUTE_PATH <path> [BASE_DIRECTORY <path>] [NORMALIZE]
  282. [OUTPUT_VARIABLE <output>])
  283. If ``<path>`` is a relative path, it is evaluated relative to the given base
  284. directory specified by ``BASE_DIRECTORY`` option. If no base directory is
  285. provided, the default base directory will be
  286. :variable:`CMAKE_CURRENT_SOURCE_DIR`.
  287. When ``NORMALIZE`` option is specified, the path is :ref:`normalized
  288. <NORMAL_PATH>` after the path computation.
  289. Because ``cmake_path`` does not access to the filesystem, symbolic links are
  290. not resolved. To compute a real path, use :command:`get_filename_component`
  291. command with ``REALPATH`` sub-command.
  292. Conversion
  293. ^^^^^^^^^^
  294. .. _cmake_path-CMAKE_PATH:
  295. .. _CMAKE_PATH:
  296. .. code-block:: cmake
  297. cmake_path(CMAKE_PATH <path> [NORMALIZE] <input>)
  298. Converts a native ``<input>`` path into cmake-style path with forward-slashes
  299. (``/``). On Windows, the long filename marker is taken into account.
  300. When ``NORMALIZE`` option is specified, the path is :ref:`normalized
  301. <NORMAL_PATH>` before the conversion.
  302. .. _cmake_path-NATIVE_PATH:
  303. .. _NATIVE_PATH:
  304. .. code-block:: cmake
  305. cmake_path(NATIVE_PATH <path> [NORMALIZE] <output>)
  306. Converts a cmake-style ``<path>`` into a native
  307. path with platform-specific slashes (``\`` on Windows and ``/`` elsewhere).
  308. When ``NORMALIZE`` option is specified, the path is :ref:`normalized
  309. <NORMAL_PATH>` before the conversion.
  310. .. _CONVERT:
  311. .. _cmake_path-TO_CMAKE_PATH_LIST:
  312. .. _TO_CMAKE_PATH_LIST:
  313. .. code-block:: cmake
  314. cmake_path(CONVERT <input> TO_CMAKE_PATH_LIST <output> [NORMALIZE])
  315. Converts a native ``<input>`` path into cmake-style path with forward-slashes
  316. (``/``). On Windows, the long filename marker is taken into account. The input can
  317. be a single path or a system search path like ``$ENV{PATH}``. A search path
  318. will be converted to a cmake-style list separated by ``;`` characters. The
  319. result of the conversion is stored in the ``<output>`` variable.
  320. When ``NORMALIZE`` option is specified, the path is :ref:`normalized
  321. <NORMAL_PATH>` before the conversion.
  322. .. _cmake_path-TO_NATIVE_PATH_LIST:
  323. .. _TO_NATIVE_PATH_LIST:
  324. .. code-block:: cmake
  325. cmake_path(CONVERT <input> TO_NATIVE_PATH_LIST <output> [NORMALIZE])
  326. Converts a cmake-style ``<input>`` path into a native path with
  327. platform-specific slashes (``\`` on Windows and ``/`` elsewhere). The input can
  328. be a single path or a cmake-style list. A list will be converted into a native
  329. search path. The result of the conversion is stored in the ``<output>``
  330. variable.
  331. When ``NORMALIZE`` option is specified, the path is :ref:`normalized
  332. <NORMAL_PATH>` before the conversion.
  333. Comparison
  334. ^^^^^^^^^^
  335. .. _COMPARE:
  336. .. code-block:: cmake
  337. cmake_path(COMPARE <path> EQUAL <input> <output>)
  338. cmake_path(COMPARE <path> NOT_EQUAL <input> <output>)
  339. Compares the lexical representations of the path and another path.
  340. For testing equality, the following algorithm (pseudo-code) apply:
  341. .. code-block:: cmake
  342. IF (NOT <path>.root_name() STREQUAL <input>.root_name())
  343. returns FALSE
  344. ELSEIF (<path>.has_root_directory() XOR <input>.has_root_directory())
  345. returns FALSE
  346. ENDIF()
  347. returns TRUE or FALSE if the relative portion of <path> is
  348. lexicographically equal or not to the relative portion of <input>.
  349. Comparison is performed path component-wise
  350. Query
  351. ^^^^^
  352. .. _HAS_ROOT_NAME:
  353. .. code-block:: cmake
  354. cmake_path(HAS_ROOT_NAME <path> <output>)
  355. Checks if ``<path>`` has ``root-name``.
  356. .. _HAS_ROOT_DIRECTORY:
  357. .. code-block:: cmake
  358. cmake_path(HAS_ROOT_DIRECTORY <path> <output>)
  359. Checks if ``<path>`` has ``root-directory``.
  360. .. _HAS_ROOT_PATH:
  361. .. code-block:: cmake
  362. cmake_path(HAS_ROOT_PATH <path> <output>)
  363. Checks if ``<path>`` has root path.
  364. Effectively, checks the following: ``root-name / root-directory``.
  365. .. _HAS_FILENAME:
  366. .. code-block:: cmake
  367. cmake_path(HAS_FILENAME <path> <output>)
  368. Checks if ``<path>`` has ``file-name``.
  369. .. _HAS_EXTENSION:
  370. .. code-block:: cmake
  371. cmake_path(HAS_EXTENSION <path> <output>)
  372. Checks if ``<path>`` has an :ref:`<extension <EXTENSION_DEF>`. If the first
  373. character in the filename is a period, it is not treated as an extension (for
  374. example ".profile").
  375. .. _HAS_STEM:
  376. .. code-block:: cmake
  377. cmake_path(HAS_STEM <path> <output>)
  378. Checks if ``<path>`` has stem.
  379. .. _HAS_RELATIVE_PATH:
  380. .. code-block:: cmake
  381. cmake_path(HAS_RELATIVE_PATH <path> <output>)
  382. Checks if ``<path>`` has relative path.
  383. .. _HAS_PARENT_PATH:
  384. .. code-block:: cmake
  385. cmake_path(HAS_PARENT_PATH <path> <output>)
  386. Checks if ``<path>`` has parent path.
  387. .. _IS_ABSOLUTE:
  388. .. code-block:: cmake
  389. cmake_path(IS_ABSOLUTE <path> <output>)
  390. Checks if ``<path>`` is absolute.
  391. An absolute path is a path that unambiguously identifies the location of a file
  392. without reference to an additional starting location.
  393. .. _IS_RELATIVE:
  394. .. code-block:: cmake
  395. cmake_path(IS_RELATIVE <path> <output>)
  396. Checks if path is relative.
  397. .. _IS_PREFIX:
  398. .. code-block:: cmake
  399. cmake_path(IS_PREFIX <path> <input> [NORMALIZE] <output>)
  400. Checks if ``<path>`` is the prefix of ``<input>``.
  401. When ``NORMALIZE`` option is specified, the paths are :ref:`normalized
  402. <NORMAL_PATH>` before the check.
  403. Hashing
  404. ^^^^^^^
  405. .. _HASH:
  406. .. code-block:: cmake
  407. cmake_path(HASH <path> [NORMALIZE] <output>)
  408. Compute hash value of ``<path>`` such that if for two paths (``p1`` and ``p2``)
  409. are equal (:ref:`COMPARE ... EQUAL <COMPARE>`) then hash value of p1 is equal
  410. to hash value of p2.
  411. When ``NORMALIZE`` option is specified, the paths are :ref:`normalized
  412. <NORMAL_PATH>` before the check.