[cmake-developers] [CMake 0016102]: target_include_directories behaves differently on STATIC and SHARED libraries

Mantis Bug Tracker mantis at public.kitware.com
Thu May 12 18:09:35 EDT 2016


The following issue has been SUBMITTED. 
====================================================================== 
https://cmake.org/Bug/view.php?id=16102 
====================================================================== 
Reported By:                pboettch
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   16102
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2016-05-12 18:09 EDT
Last Modified:              2016-05-12 18:09 EDT
====================================================================== 
Summary:                    target_include_directories behaves differently on
STATIC and SHARED libraries
Description: 
Consider the following CMakeLists.txt:

  add_library(lib1 INTERFACE)
  target_include_directories(lib1 INTERFACE /lib1-dir)
 
  add_library(lib3 STATIC src3.c)
  target_include_directories(lib3 PUBLIC /lib3-dir)
  target_link_libraries(lib3 PRIVATE lib1)

  add_executable(exe1 exe.c)
  target_link_libraries(exe1 lib3)

Here lib3 is privately linking with lib1. However, during the compilation of
exe.c I see -I/lib1-dir is passed to gcc. 

When creating lib3 as a SHARED library it works as expected.

I understand that lib1 needs to be linked to exe1 if lib3 is STATIC and that
this not necessary when lib3 is SHARED.

However this logic does not apply for include_directories (or
compile-definitions and compile-options), which should, IMHO, never be passed on
if link is PRIVATE. Hence this bug-report.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2016-05-12 18:09 pboettch       New Issue                                    
======================================================================



More information about the cmake-developers mailing list