[CMake] Header files excluded from build in Visual Studio

Claus Höfele claus at claushoefele.com
Thu Mar 12 22:34:00 EDT 2009


Hi everyone,

I've recently switched to cmake to generate Visual Studio project
files for a project of mine and it's working great so far.

One issue that bugs me is that header files end up being disabled in
Visual Studio (Excluded From Build property is set for the header
files). This prevents Visual Studio from syntax checking these files,
which is quite a bummer for me because I have a lot of inline code in
my header files.

Setting the property HEADER_FILE_ONLY to false doesn't work because
the code in cmSourceFile::CheckExtension() forces this property to
true for headers files. The generator for Visual Studio then
automatically disables the file when it writes the project file.

For Visual Studio, this behaviour doesn't make much sense because
header files are not compiled anyway. At the very minimum, I should be
able to override this setting.

I wonder if there's a workaround for this problem without resorting to
building my own cmake executable.

Thanks,
Claus


More information about the CMake mailing list