How to force CMake’s target_include_directories() to use absolute path

How do I force CMake's function target_include_directories() to treat the value as an absolute path?

For example, I want this line of code:

target_include_directories(foobar  PRIVATE   "%FOOBAR_INCLUDE%")

to simply add %FOOBAR_INCLUDE% to the list of include directories.

However, what we actually get is c:\path\to\foobar\%FOOBAR_INCLUDE%.

I know that I could do

target_include_directories(foobar  PRIVATE   "$ENV{FOOBAR_INCLUDE}")

but that's not what I want. That would expand the value of the environment variable and insert the current setting of the FOOBAR_INCLUDE value.

We need for it to simply push the environment variable, and then during development the developers will change the value of FOOBAR_INCLUDE manually without having to re-run CMake each time.

Read more here:

Content Attribution

This content was originally published by John Rocha at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: