MantisBT - CMake
View Issue Details
0015362CMakeCMakepublic2015-01-19 19:442015-07-08 08:57
Clinton Stimpson 
Stephen Kelly 
normalminorhave not tried
closedfixed 
 
CMake 3.2 
0015362: Target property INTERFACE_SYSTEM_INCLUDE_DIRECTORIES doesn't seem to work
I had some code doing
set_property(TARGET A APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")

And I replaced INTERFACE_INCLUDE_DIRECTORIES with INTERFACE_SYSTEM_INCLUDE_DIRECTORIES, and it no longer worked.

I understand the different to be equivalent to
include_directories(...)
vs.
include_directories(SYSTEM ...)


See attached project for an example which doesn't work.
No tags attached.
gz test-usage-includes.tar.gz (619) 2015-01-19 19:44
https://public.kitware.com/Bug/file/5352/test-usage-includes.tar.gz
Issue History
2015-01-19 19:44Clinton StimpsonNew Issue
2015-01-19 19:44Clinton StimpsonFile Added: test-usage-includes.tar.gz
2015-01-19 19:52Clinton StimpsonNote Added: 0037754
2015-01-21 13:58Clinton StimpsonNote Added: 0037763
2015-01-22 18:19Stephen KellyNote Added: 0037782
2015-01-22 18:19Stephen KellyStatusnew => resolved
2015-01-22 18:19Stephen KellyFixed in Version => CMake 3.2
2015-01-22 18:19Stephen KellyResolutionopen => fixed
2015-01-22 18:19Stephen KellyAssigned To => Stephen Kelly
2015-07-08 08:57Robert MaynardNote Added: 0039032
2015-07-08 08:57Robert MaynardStatusresolved => closed

Notes
(0037754)
Clinton Stimpson   
2015-01-19 19:52   
I tried CMake 3.1 initially, but also tried 2.8.12 where the feature was introduced... and it doesn't work there either.
(0037763)
Clinton Stimpson   
2015-01-21 13:58   
I found a way to get what I wanted.

I'm trying to add INTERFACE_INCLUDE_DIRECTORIES for an imported target, and have a way to suppress compile warnings from those header files.

CMake 3.0 and greater will do that for me automatically, which is nice.
However, for 2.8.12 users, I've added a CMake version check and I use INTERFACE_COMPILE_OPTIONS to use the -isystem flag myself.

Still, the documented INTERFACE_SYSTEM_INCLUDE_DIRECTORIES doesn't in any version of CMake I've tried. It appears to be introduced in 2.8.12, and deprecated in 3.0. The documentation doesn't reflect the state of the feature.
(0037782)
Stephen Kelly   
2015-01-22 18:19   
Hi,

1)

I tried this:

  add_library(iface INTERFACE)
  set_property(TARGET iface PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
    "${CMAKE_CURRENT_SOURCE_DIR}/iface"
  )
  set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES
    "${CMAKE_CURRENT_SOURCE_DIR}/iface"
  )

  add_executable(main main.cpp)
  target_link_libraries(main iface)

and it works fine. Note that the only source of include directories is the INTERFACE_INCLUDE_DIRECTORIES property. The INTERFACE_SYSTEM_INCLUDE_DIRECTORIES property only specifies which of those in INTERFACE_INCLUDE_DIRECTORIES should be treated as SYSTEM. So, essentially, they have to be specified twice.

2)
Your example also works fine when the directory is specified in INTERFACE_INCLUDE_DIRECTORIES too:

  set_property(TARGET iface PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
    "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/iface>"
  )
  set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES
    "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/iface>"
  )

3)

If you use target_include_directories there is no repetition:

  target_include_directories(iface SYSTEM INTERFACE
    "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/iface>"
  )

So, taking all of the above together, the feature works, but the documentation should be clarified. The source of include directories is the INTERFACE_INCLUDE_DIRECTORIES and INCLUDE_DIRECTORIES, not anything else.

4) There *is* a bug that the CONFIG generator expression does not work.

 http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=85857e6d [^]
 85857e6d Help: Clarify INTERFACE_SYSTEM_INCLUDE_DIRECTORIES documentation.

 http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee38062b [^]
 ee38062b IncludeDirectories: Respect SYSTEM flag when using CONFIG genex.
(0039032)
Robert Maynard   
2015-07-08 08:57   
Closing resolved issues that have not been updated in more than 4 months.