Reputation: 7881
Is there a CMake command that returns true if and only if two paths point to the same place (even if the paths are not verbatim equal strings)?
Something like
set(x ../foo)
set(y C:/cmaketest/foo)
if (x PATHEQUAL y)
{
message(status "YAY")
}
Upvotes: 4
Views: 1557
Reputation: 81916
This should mostly work. The one case that it doesn't appear to take into account is filesystems that are not case-sensitive (This includes the default file systems on OS X and Windows, but does not include Linux).
get_filename_component(x ./foo.txt ABSOLUTE)
get_filename_component(y ././foo.txt ABSOLUTE)
if (x STREQUAL y)
message(STATUS "Strings are Equal")
else()
message(STATUS "Strings are Not Equal")
endif()
This outputs:
[11:55am][wlynch@watermelon blah] touch foo.txt
[11:55am][wlynch@watermelon blah] cmake . |& head -n 1
-- Strings are Equal
Upvotes: 6