Skip to content

Allow target_include_directories to specify INTERFACE for IMPORTED targets

This issue was created automatically from an original Mantis Issue. Further discussion may take place here.


When target_include_directories is used with an INTERFACE option on an IMPORTED target, the command fails with an error.

Since I specified INTERFACE and not PUBLIC or PRIVATE, I should expect the command to work without error on the IMPORTED target.

As a workaround, I have to use the more verbose set_property command.

add_library(MyLib SHARED IMPORTED)
set_property(TARGET MyLib PROPERTY IMPORTED_LOCATION mylib.dll)
set_property(TARGET MyLib PROPERTY IMPORTED_IMPLIB mylib.lib)

# Following line fails with an error:
target_include_directories(MyLib INTERFACE mylib/include)
# The error is:
# Cannot specify include directories for imported target "MyLib".
# Alternative command that works:
# set_property(TARGET MyLib APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES mylib/include)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information