Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake many INTERFACE_INCLUDE_DIRECTORIES

Tags:

cmake

I'm creating an imported target which wishes to expose two interface include directories:

list(APPEND LIB_INCLUDE_DIRS "dir1")
list(APPEND LIB_INCLUDE_DIRS "dir2")

add_library(lib SHARED IMPORTED GLOBAL)
set_target_properties(
    lib
    PROPERTIES
    IMPORTED_LOCATION "something"
    INTERFACE_INCLUDE_DIRECTORIES ${LIB_INCLUDE_DIRS}
)

Unfortunately, there's an error: set_target_properties called with incorrect number of arguments.

If I try to set only the first directory, it works. Is there a way to set both? Or is the plural form of INTERFACE_INCLUDE_DIRECTORIES simply ironic?

like image 695
krojew Avatar asked Feb 28 '17 13:02

krojew


1 Answers

Just put the directory list in quotes

set_target_properties(
    lib
    PROPERTIES
    IMPORTED_LOCATION "something"
    INTERFACE_INCLUDE_DIRECTORIES "${LIB_INCLUDE_DIRS}"
)

Otherwise the list is expanded again into parameters.

References

  • cmake: when to quote variables?
like image 79
Florian Avatar answered Oct 09 '22 22:10

Florian