[CMake] header files with visual studio

Oliver kfsone Smith osmith at playnet.com
Mon Nov 15 12:29:17 EST 2010


Michael Jackson said the following on 11/15/2010 9:33 AM:
>
> 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.
Ah - you've kind of both missed the nuance.

The very last thing I want is one singular header list. Infact, the 
header lists for any given project will be relatively small (potentially 
hundreds of headers, but not thousands).

The scanner only has to search the source files listed under "+ Sources" 
for each project and only has to include the resulting headers. The 
lists are thus likely to be relatively small and pretty easily generated.

The result would be

+- Solution
|  +- Target 1
|  |  +- Sources
|  |  +- Headers
|  +- Target 2
|  |  +- Sources
|  |  +- Headers
...

instead of

+- Solutions
|  +- Target 1
|  |  +- Sources
|  +- Target 2
|  |  +- Sources
|  +- Target 3
|  |  +- Sources
...

Caveat: a header may appear under more than one target for a given 
CMakeLists/solution/cbp file, but that's ok.


- Oliver



More information about the CMake mailing list