[CMake] header files with visual studio

Michael Jackson mike.jackson at bluequartz.net
Mon Nov 15 10:33:56 EST 2010


On Nov 15, 2010, at 9:50 AM, Bill Hoffman wrote:

> On 11/14/2010 5:00 AM, Eric Noulard wrote:
>
>> There has been some discussion on the list about improvement
>> of the dependency scanner, this kind of idea may be examined there.
>> May be it's worth filing a feature request on this subject.
>>
>
> I have not followed this too closely.  However, I thought might add  
> a few things. To date CMake does NOT run the dependency program at  
> CMake time, but rather at build time. In addition for the VS IDE it  
> is NEVER run, as VS does its own dependency scanning.   So, it would  
> be a big change for CMake to do this at CMake time.  My fear would  
> be that it would be VERY slow.  If this is to handle 5000 header  
> files, I am guessing the VS IDE would choke on loading them anyway.   
> For most C++ projects I working on there is a one to one mapping  
> between C++ classes in .cxx and class definitions in .h files.  So,  
> you usually add the .h when you add the .cxx, your you could even  
> have a macro that adds both automatically.  However, a scanner that  
> auto-adds the .h files seems a bit heavy handed, and would have  
> serious performance issues.
>
>
> -Bill

I have been casually following this thread and I understand the OPs  
hesitation when trying to add thousands of files into a CMake build  
system but what I think one needs to think about is that you are only  
going to add the files ONCE for the project. After that the CMake  
files are correctly created and any other additions are in the form of  
only a few files at a time during the course of normal development.  
What I end up doing in the cases where this happened to me was to  
create my CMake files and figure out what needs to added to a CMake  
file and the syntax that it needs to be added in. Then a one off shell  
script (or pick your favorite language) is created to look at the  
project, get a list of files needed, then "generate" a CMake file that  
can be incorporated into your project. After that is done the shell  
script is no longer needed because you have your CMake files and you  
will not need your dependency analysis tool because CMake and/or  
Visual Studio will have what it needs.

You can place the CMake code in files called "Sources.cmake" in each  
source directory then have your higher level CMake files simply  
"include" Sources.cmake for each project. Yes there is development  
time for this but the shell script does not have to be pretty or  
efficient. It is only going to be run once to generate the cmake files.
___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson at bluequartz.net
BlueQuartz Software               Dayton, Ohio





More information about the CMake mailing list