View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0016102CMakeCMakepublic2016-05-12 18:092016-05-15 07:45
Reporterpboettch 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformLinuxOSDebianOS VersionStretch
Product VersionCMake 3.5.2 
Target VersionFixed in Version 
Summary0016102: target_include_directories behaves differently on STATIC and SHARED libraries
DescriptionConsider 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.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0041064)
Brad King (manager)
2016-05-13 08:56

This functionality depends on CMP0022 being set to NEW. Use

  cmake_minimum_required(VERSION 2.8.12) # or higher

at the top of your top-level CMakeLists.txt file to make this happen.

 Issue History
Date Modified Username Field Change
2016-05-12 18:09 pboettch New Issue
2016-05-13 08:56 Brad King Note Added: 0041064
2016-05-13 08:56 Brad King Status new => resolved
2016-05-13 08:56 Brad King Resolution open => no change required
2016-05-13 08:56 Brad King Steps to Reproduce Updated
2016-05-15 07:45 pboettch Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team