Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake command for paths are equal

Tags:

c++

cmake

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")
}
like image 364
IdeaHat Avatar asked Oct 16 '25 11:10

IdeaHat


1 Answers

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
like image 147
Bill Lynch Avatar answered Oct 18 '25 12:10

Bill Lynch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!