[CMake] Full source path in generated ninja build file?

Chaoren Lin chaorenl at google.com
Wed May 25 14:54:21 EDT 2016


Hi, currently if the build directory is under the project's root, and the
generator is ninja, the generated build files will use relative paths from
the build directory for the source files.

E.g., if we have a project and its build directory structured like this:

project/
    CMakeLists.txt
    src/
        foo.cpp
    build/
        CMakeCache.txt
        CMakeFiles/...
        build.ninja

build.ninja will contain something like this:

build CMakeFiles/foo.dir/src/foo.cpp.o: CXX_COMPILER_foo ../src/foo.cpp

Now, when you build, and get a compile error, the reported path would be
relative to the build directory. This is a somewhat problematic if the
build is being run through an IDE that has no concept of the build
directory (e.g., it's only supplied with a build command, no concept of
what's in the command), since the IDE then can't do anything with the
relative path that comes out of the compiler error. The IDE won't be able
to open the correct source file when receiving the error.

Currently source files in the ninja generator are converted to "NinjaPath"
which are just full paths converted to HOME_OUTPUT. Is there a reason we
can't just always use full paths for the source files?

Thanks,
Chaoren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160525/f62a9209/attachment.html>


More information about the CMake mailing list