[CMake] cmake uses -I instead -isystem when linking private against a library

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Fri Sep 4 15:43:03 EDT 2015


Hi,

It looks like '-isystem' is replaced by '-i' from the compile line as 
soon as the library which defined the path as system include path is 
linked as 'PRIVATE'.
See this testcase:

project(isystem)
cmake_minimum_required(VERSION 3.0)

add_library(lib1 SHARED foo.cpp)
set_property(TARGET lib1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES        
${CMAKE_SOURCE_DIR}/include)
set_property(TARGET lib1 PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES 
${CMAKE_SOURCE_DIR}/include)

add_library(lib2 SHARED foo.cpp)
target_link_libraries(lib2
   PUBLIC
     lib1
)
add_library(lib3 SHARED foo.cpp)
target_link_libraries(lib3
   PRIVATE
     lib1
   PUBLIC
     lib2
)
add_library(lib4 SHARED foo.cpp)
target_link_libraries(lib4
   PUBLIC
     lib3
)

now lib4.cpp is compiled with -I ${CMAKE_SOURCE_DIR}/include ...

I'm not quite sure if the dependency chain is valid here and it can be 
easily fixed by moving lib1 from PRIVATE to PUBLIC in 
target_link_libraries(lib3) but since lib3 links public to lib2 and lib2 
public to lib1 I expected that lib4 should also use '-isystem'

Should I file a bug report on this?
Christian





More information about the CMake mailing list