[cmake-developers] include_directories is broken with ninja generator

Matthew Woehlke matthew.woehlke at kitware.com
Wed Mar 13 21:33:16 EDT 2013


On 2013-03-13 20:59, Matthew Woehlke wrote:
> This simple CMakeLists.txt is broken with ninja:
>
> cmake_minimum_required(VERSION 2.8.10.20130312)
> project(Foo)
>
> add_executable(foo foo.cpp)
>
> target_include_directories(foo PUBLIC
>    $<BUILD_INTERFACE:${Foo_BINARY_DIR}>
>    $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
> )
>
> ...with Ninja, the include directive passed to the compiler is '-I.'
> (with the binary dir prefix similarly stripped for anything after the ${}).
>
> It seems okay with the Makefile generator.
>
> This does appear to be a CMake problem, and not a ninja problem, as in
> the build.ninja I am seeing 'FLAGS = -I.'.
>
> It would be nice to have this fixed before 2.8.11 final :-).

The problem is definitely in 
cmLocalGenerator::ConvertToOutputForExisting. I suspect this is failing 
because it sees the relative root as always CMAKE_BINARY_DIR, since that 
is the only directory to which build files get written (and works with 
Makefiles because the relative root is CMAKE_CURRENT_BINARY_DIR).

Further, it seems to happen with include_directories also... and 
apparently it has always been broken (at least with 2.8.10.2 also).

-- 
Matthew




More information about the cmake-developers mailing list