Ninja generator uses relative paths for target_include_directories()
If I add ${CMAKE_BINARY_DIR}
to a target with target_include_directories()
the Ninja generator will replace that with a -I.
instead of the absolute path like the Unix Makefile generator. This causes issues with the Eclipse GCC Output Parser that doesn't understand the change directory Ninja does before executing the compile command.
I've attached a log and a CMakeLists.txt that shows this behaviour.
With Ninja I get the following command
[2/3] /usr/bin/cc -I. -MD -MT CMakeFiles/foo.dir/foo.c.o -MF CMakeFiles/foo.dir/foo.c.o.d -o CMakeFiles/foo.dir/foo.c.o -c foo.c
With Unix Makefiles I get this instead
/usr/bin/cc -I/home/jonas/cmake_bug/build -o CMakeFiles/foo.dir/foo.c.o -c /home/jonas/cmake_bug/build/foo.c
I would expect that both would generate the same -I arguments to cc.
A workaround is to prefix the path with '/.' which causes it to emit an absolute path instead.
Thanks.