MantisBT - CMake
View Issue Details
0015788CMakeCMakepublic2015-10-13 11:472016-03-07 09:12
SunBlack 
 
normalminoralways
closedno change required 
Windows8.1
CMake 3.3.2 
 
0015788: Error during export target, which has additional defined include directories with target_include_directories
If you have a static library and want to add necessary include directories with target_include_directories so users of this library just need to add library with target_link_libraries (and don't need to add includes with include_directories), I currently got

%%Configuring done
CMake Error in CMakeLists.txt:
  Target "myProject" INTERFACE_INCLUDE_DIRECTORIES property contains path:

    "D:/myProjectDir/myIncludeDir"

  which is prefixed in the source directory.


Generating done%%

Source code:
%%cmake_minimum_required(VERSION 3.3)

project(myProject)

add_library(${PROJECT_NAME}
    mySourceDir/test.cpp
    myIncludeDir/test.h
)

target_include_directories(${PROJECT_NAME} PUBLIC "myIncludeDir")

install(TARGETS ${PROJECT_NAME}
    EXPORT MyTargets
    ARCHIVE DESTINATION lib
)

install(EXPORT MyTargets DESTINATION cmake)%%

This message don't occurs, if I remove install.
No tags attached.
Issue History
2015-10-13 11:47SunBlackNew Issue
2015-10-13 11:52Brad KingNote Added: 0039594
2015-10-13 11:52Brad KingStatusnew => resolved
2015-10-13 11:52Brad KingResolutionopen => no change required
2016-03-07 09:12Robert MaynardNote Added: 0040616
2016-03-07 09:12Robert MaynardStatusresolved => closed

Notes
(0039594)
Brad King   
2015-10-13 11:52   
This is a feature. CMake is preventing you from adding a public dependency on your source tree for users of your install tree. See the $<BUILD_INTERFACE:...> and $<INSTALL_INTERFACE:...> expressions and the example here:

 https://cmake.org/cmake/help/v3.4/manual/cmake-buildsystem.7.html#include-directories-and-usage-requirements [^]
(0040616)
Robert Maynard   
2016-03-07 09:12   
Closing resolved issues that have not been updated in more than 4 months.