Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use environment variable to set `include_directories`

I have an environment variable that contains paths to manually 'installed' header only libraries:

export INCLUDE_PATH="/some/path":"${INCLUDE_PATH}"

I want to use this in my CMakeLists.txt. But when I do:

include_directories("$ENV{INCLUDE_PATH}")

the paths appear not be properly added (no CMake error, but the compiler does not know where to look).

like image 827
Tom de Geus Avatar asked Nov 21 '25 13:11

Tom de Geus


1 Answers

You can try to replace the ':' char to ';'. The ';' is the way CMake deals with lists.

string(REPLACE ":" ";" INCLUDE_LIST $ENV{INCLUDE_PATH})

include_directories(${INCLUDE_LIST})
like image 112
Tomaz Canabrava Avatar answered Nov 24 '25 22:11

Tomaz Canabrava