I was reading through the documentation for the upcoming cmake_path()
command that will replace most of the file(foo_PATH ...)
subcommands in the next release, and I’m finding some of them… both non-obvious, and unhelpfully documented.
IS_RELATIVE
and IS_ABSOLUTE
, those make sense to me, their workings are obvious. Many of the rest, though…
cmake_path(HAS_ROOT_NAME <path> <output>)
Checks if
<path>
hasroot-name
.
cmake_path(HAS_ROOT_DIRECTORY <path> <output>)
Checks if
<path>
hasroot-directory
.
Since these aren’t documented as taking inputs for root-name
and root-directory
, I have no real idea what they’re supposed to do.
cmake_path(HAS_ROOT_PATH <path> <output>)
Checks if
<path>
has root path.Effectively, checks the following:
root-name / root-directory
.
Given the above, this one is even more confusing.
cmake_path(HAS_FILENAME <path> <output>)
Checks if
<path>
hasfile-name
.
Again, since file-name
isn’t an input, I’m confused. I’d assume this checks whether the path has any filename — meaning, it doesn’t end in a slash. But then file-name
should just be “a filename component” or something like that.
cmake_path(HAS_EXTENSION <path> <output>)
Checks if
<path>
has an <extension. If the first character in the filename is a period, it is not treated as an extension (for example “.profile”).
This makes me even more convinced I’m correct about the previous one, since they would be complementary.
cmake_path(HAS_STEM <path> <output>)
Checks if
<path>
has stem.
Aaaand, we’re back to “I have no idea what this means”.
cmake_path(HAS_RELATIVE_PATH <path> <output>)
Checks if
<path>
has relative path.
How is this different from “IS_RELATIVE”? They sound redundant.
cmake_path(HAS_PARENT_PATH <path> <output>)
Checks if
<path>
has parent path.
Yup, again, no clue what that means. How can a path “have” a parent path — and not even a specific one, just any arbitrary parent path?
A pair of commands like…
cmake_path(IS_PARENT_OF <path> <child> <output>)
cmake_path(IS_CHILD_OF <path> <parent> <output>)
that would make sense to me. I could totally see the utility in that. And, actually, I guess that first one is cmake_path(IS_PREFIX_OF <path> <input>)
, so that’s cool. And I suppose you could just reverse <path>
and <input>
to get the other operation. So that only leaves me, again, even more confused about what all those other commands are supposed to be doing.
I just can’t figure out how, when, or why most of these would be used. And the current documentation only makes it less clear.