[cmake-developers] [CMake 0014648]: Need an option to skip system headers while generating dependencies

Mantis Bug Tracker mantis at public.kitware.com
Sun Dec 15 08:32:16 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14648 
====================================================================== 
Reported By:                Robert·Luberda
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14648
Category:                   (No Category)
Reproducibility:            always
Severity:                   major
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2013-12-15 08:32 EST
Last Modified:              2013-12-15 08:32 EST
====================================================================== 
Summary:                    Need an option to skip system headers while
generating dependencies
Description: 
There is currently no way to tell cmake not to consider system headers while
generating dependencies. 

If the source file contain for example the following includes:
#include <iostream>
#include <boost/lexical_cast.hpp>
#include <tbb/atomic.hpp>
#include <unistd.h>
#include <sys/types.h>
#include "projectdir1/header1.h"
#include "projectdir2/header2.hpp"
#include "header3.h"

then CMake will try to find each of the file in the directories given by
include_directories(), which has a *huge* performance impact on build process
when CMake happens to actually find the files (please note that CMake does not
consider some system dirs like /usr/include or  /usr/include/c++/4.8 by default,
and that's why the issue is somehow hidden. BTW. This is a really strange - why
e.g. boost header from /usr/include are treated differently than those ones from
/opt/boost-1.55.0/include?).

However the system header files do not change often, and can be ignored by CMake
in a two ways:
- by ignoring the files that are #included inside the < > brackets
- by ignoring directories that are marked as SYSTEM ones during scanning for
files (it could by some new property like NOT-FOR-DEPS instead of SYSTEM), just
like `g++ -MM' does (and you know, g++ provides such an option for a reason...)

I assume there might be some projects that require dependencies for system
headers, so that features need to be configurable. And yes, in my opinion it
would be nice to have both of the features implemented, it really shouldn't be a
rocket science.

The currently provided features does not fix the issue:
- include_regular_expression() is not a solution, as it's hardly possible to
enumerate all non-system headers with it;
- the `fast' targets are not an option either, as they ignore all the
dependencies, besides there is no `all/fast' target (see also
https://blogs.kde.org/2006/08/06/working-cmake-dependency-hell)
- there is INCLUDE_REGEX_LINE variable in CMake sources, but it seems to be
hardcoded, cannot be changed by user.

Steps to Reproduce: 
Take any really big C++ project using boost (and other libraries) from
non-standard locations (or make sure the boost headers are visible to cmake, but
using something like `include_directiories("/usr/include")') and watch the poor 
performance...

Additional Information: 
There are already two quite an old bugs about same issues:
http://public.kitware.com/Bug/view.php?id=2607
http://public.kitware.com/Bug/view.php?id=8777
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-12-15 08:32 Robert·Luberda New Issue                                    
======================================================================




More information about the cmake-developers mailing list