[CMake] target_include_directories target issue

Luis Felipe Dominguez Vega lfdominguez at estudiantes.uci.cu
Mon Nov 17 07:42:47 EST 2014


I can't see into the source code of cmake, into the 
cmTargetIncludeDirectoriesCommand.cxx somethink like import the 
INCLUDE_DIRECTORIES from target passed to target_include_directories, may an 
error in the documentation?
-----------------------------------------------------------
On Sunday 16 November 2014 11:56:05 AM Wojciech Mamrak wrote:
> Hello,
> 
> the docs claim:
> 
> "Specify include directories or targets to use when compiling a given
> target."
> 
> Here is a little test of it. Project directory:
> 
> Foo
>   CMakeLists.txt
>   FooSrc
>     a.h
>     a.cpp
>   Bar
>     main.cpp
> 
> And CMakeLists.txt:
> 
> cmake_minimum_required(VERSION 3.0)
> 
> project(FooBar)
> 
> add_library(Foo FooSrc/a.h FooSrc/a.cpp)
> 
> target_include_directories(Foo PUBLIC G:/some_directory)
> 
> if (TARGET Foo)
>     message("Foo is a target!")
> endif()
> 
> add_executable(Bar Bar/main.cpp)
> 
> target_include_directories(Bar PRIVATE Foo)
> 
> According to the docs, Bar's include directories should contain at
> least "G:/some_directory", but it contains
> "${PROJECT_SOURCE_DIR}/Foo". Why?
> 
> If I replace the last line with target_link_libraries(Bar PRIVATE
> Foo), then Bar's include directories meet my expectations.
> 
> regards



More information about the CMake mailing list