0

I have a space separated string that represents include directories I'd like to add, let's call it ${MYSTRING}, and let's say it contains the stringmy/dir1 my/dir2 my/dir3.

Using:

include_directories(${MYSTRING})

Results in an incorrect makefile, as the CXX_FLAGS that is added is:

-Imy/dir1 my/dir2 my/dir3

Rather than:

-Imy/dir1 -Imy/dir2 -Imy/dir3

Is there anyway I can work around this? the string is generated via an external command, and I'd rather not have to depend on external tools such as sed.

Cœur
  • 37,241
  • 25
  • 195
  • 267
nbubis
  • 2,304
  • 5
  • 31
  • 46
  • 3
    Possible duplicate of [What is common way to split string into list with CMAKE?](http://stackoverflow.com/questions/5272781/what-is-common-way-to-split-string-into-list-with-cmake) – nbubis Dec 31 '16 at 21:38

1 Answers1

0

Use separate_arguments which takes a space-separated string of values and turns it into a list:

set(MY_LIST ${MYSTRING})
separate_arguments(MY_LIST)
include_directories(${MY_LIST})
Cinder Biscuits
  • 4,880
  • 31
  • 51