[CMake] CMake error reporting with absolute paths?

Kevin Funk krf at gmx.de
Fri Jul 26 03:35:55 EDT 2013


Hey there,

I've been wondering if that topic came up at some point:

CMake currently does the following error reporting in case something goes 
wrong: 

Output:
"""
CMake Error at src/CMakeLists.txt:14 (add_executable):

(...)
"""

So, while this is fine at a first glance, it isn't exactly easy to parse for 
both humans and machines because the message doesn't tell you the absolute 
file path. You have a to know about the base folder to find out the absolute 
path. Which is the CMake project root folder, right.

This question came up in order to fix a bug [1] in KDevelop -- KDevelop has 
CMake support and also provides parsing CLI output to some extend. It can 
parse command-line output and provide clickable entries for quickly opening 
the relevant file in case of errors.

The problematic part is that for CMake one cannot easily parse the line "CMake 
Error at src/CMakeLists.txt:14 (add_executable):" because, again, you have to 
maintain a context to find the absolute path. So, while it is of course 
possible to achieve this (pass the CMake root to the output parser), it is a 
bit cumbersome to do so because other compilers/Makefile-generators tend to 
use absolute paths in error reporting.

So, keeping it short: In my opinion it would make sense to use absolute paths 
in such scenarios (error reporting). Both to simplify parsing CMake output for 
third-party tools and for making it easier to find the relevant file when 
running CMake manually.

What do others think?

Greets

[1] https://bugs.kde.org/show_bug.cgi?id=321982

-- 
Kevin Funk


More information about the CMake mailing list