[CMake] Header files excluded from build in Visual Studio

Bill Hoffman bill.hoffman at kitware.com
Thu Mar 12 22:47:05 EDT 2009


Claus Höfele wrote:
> 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.
> 

Well, looks like you found the reason that this fix needs fixing!

Sadly it does require a rebuild of CMake, there is no way to fix this 
without changing the c++ source code.

-Bill


More information about the CMake mailing list