Carlo Wood
Carlo Wood

Reputation: 6791

Remove some leading part from a path in cmake?

I have an absolute path set in CW_PROJECT_ROOT_DIR. For example that could be "/some/path/project".

Then I want to print CMAKE_CURRENT_SOURCE_DIR, but without the leading CW_PROJECT_ROOT_DIR part. For example, if CMAKE_CURRENT_SOURCE_DIR is "/foo/bar/some/path/project/xyz" then nothing should be stripped off, but if it is "/some/path/project/foo/bar" then just "foo/bar" should be printed.

How can I do this?

Upvotes: 0

Views: 758

Answers (1)

KamilCuk
KamilCuk

Reputation: 140880

To extract one path relative to another use file(RELATIVE_PATH <variable> <directory> <file>).

Upvotes: 1

Related Questions