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_ABSOLUTE, those make sense to me, their workings are obvious. Many of the rest, though…
cmake_path(HAS_ROOT_NAME <path> <output>)
cmake_path(HAS_ROOT_DIRECTORY <path> <output>)
Since these aren’t documented as taking inputs for
root-directory, I have no real idea what they’re supposed to do.
cmake_path(HAS_ROOT_PATH <path> <output>)
<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>)
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>)
<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>)
Aaaand, we’re back to “I have no idea what this means”.
cmake_path(HAS_RELATIVE_PATH <path> <output>)
<path>has relative path.
How is this different from “IS_RELATIVE”? They sound redundant.
cmake_path(HAS_PARENT_PATH <path> <output>)
<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
<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.