[CMake] header files with visual studio

Oliver kfsone Smith osmith at playnet.com
Tue Nov 16 18:08:42 EST 2010


Michael Jackson said the following on 11/15/2010 11:56 AM:
> Ahh. It is a bit clearer the tract you are taking. What I am 
> suggesting is that you only have to run the "scanner" once and keep 
> the results in CMake syntax files so that CMake can just simply re-use 
> the list. As you add headers during development you can add headers to 
> the lists that were generated. It is the first big lump of headers 
> which is the daunting task. After that general maintenance of the 
> CMake files is simple and straight forward.
>
> For example in the folder:
>
> +- Solution
> |  +- Target 1
> |  |  +- Sources
> |  |  +- Headers
> you can have a file Headers.cmake which contains
>
> set (TARGET_1_HEADERS foo.h bar.h other.h)
>
> which can be generated once by a script. And in the CMakelists.txt 
> file for Target 1 you can have:
> include (Headers/Headers.cmake)

It's not nearly that simple; "Target1" might be the login server, which 
uses header files from login/, chat/, etc, etc, etc. And these 
dependencies change frequently. The primary purpose is not to provide an 
SCM list of header files, but an active dependency list of header files 
so that IDE functions like "search this target only" work.

Our source layout has many "modules", but module != target. Any given 
target will have both source and header files from numerous modules/folders.

Sure, everytime we alter the #Include chain we're going to have to 
rebuild the project files from the CMakeLists, but with per-target 
dependency-generated header lists ... It becomes worth it.

- Oliver



More information about the CMake mailing list