[CMake] Listing headers in source lists

John Drescher drescherjm at gmail.com
Tue Jun 11 17:42:20 EDT 2013


> This probably seems like a silly question but:
>
> I've got a lot of "inherited" CMakefiles and I'm not a CMake expert by
> any stretch.  In all these CMakeLists.txt files I see that whenever an
> add_library or add_executable() macro is invoked, not only are the
> source files (foo.cpp etc.) included in the list of files, but also all
> the header files (foo.h etc.) are also included.
>
> Is this necessary?  Assuming these are really base files and not
> generated files, wouldn't CMake be able to handle the required header
> file inclusion computations etc. so I wouldn't have to list them
> explicitly?
>
> Can anyone comment on this?

I believe putting the headers in the target is necessary if you use
visual studio or xcode. Otherwise they will not show up in the GUI as
part of the project.

John


More information about the CMake mailing list