[CMake] Header files excluded from build in Visual Studio
Bill Hoffman
bill.hoffman at kitware.com
Fri Mar 13 09:46:29 EDT 2009
Claus Höfele wrote:
> Thanks for the quick replies.
>
> I'm using cmake 2.6.3 + Visual Studio 8 2005 SP1
>
> Playing around further with the file properties in Visual Studio, it
> looks like VS only checks the syntax of a file if the Tool property is
> set to C/C++ Compiler Tool. However, this setting will cause the
> header file to be compiled, which is obviously not what you want.
>
> So the setting for a header file should be:
> 1.) Excluded From Build: No
> 2.) Tool: Custom Build Tool
>
> 2.) is already done, 1.) is not.
>
> For my purposes, it was enough to change cmSourceFile::CheckExtension() like so:
>
> // Look for header files.
> if ...
> else
> {
> // This is a known header file extension. The source cannot be compiled.
> if(!this->GetProperty("HEADER_FILE_ONLY"))
> {
> this->SetProperty("HEADER_FILE_ONLY", "1");
> }
> }
>
> This allows me to override the HEADER_FILE_ONLY setting to false in my
> CMakeLists.txt and produces the project files I want.
>
> Would be great if a similar fix would make it into the next release.
>
What is the default if you have VS create the project? BTW, this all
came from this bug fix:
http://public.kitware.com/Bug/view.php?id=7845
I am not sure you want to make that false in your file, as the makefile
generator may then try and compile it. CMake should handle a .h file
without having to change anything.
-Bill
More information about the CMake
mailing list