[CMake] Bug? Broken header files in Visual C++ 2008 project

Thomas T. cmake.org at thomas.traenkler.com
Wed Aug 27 19:10:52 EDT 2008


Hi CMakers!

CMake is a great tool for cross-platform development, thanks!

There is just one thing that is disturbing my workflow: After searching 
the forums, and coming up with no working solution, I would like to ask 
about including headers in a Visual C++ 2008 project with cmake -G 
"Visual Studio 9 2008". Without including them, a lot of IDE features 
like code completion (IntelliSense), class browser, search and replace, 
and the file browser are broken for things that are in a library 
project's headers, so it is not really a cosmetic but a real 
productivity issue.

The problem is, CMake seems not to provide an option to specifically 
include the .h files explicitly as headers, but only as source files 
like the .cpp files. It might have worked in previous versions of Visual 
Studio, I have not tested it, but in 2008, the compiler tries to compile 
the .h files if they are passed as parameters to add_library or 
add_executable as the mailinglist archives suggest for previous versions 
of Visual Studio.

When opening the generated Visual C++ 2008 project, the header files are 
there and even in the right filter folder since I use source_group() and 
file(GLOB_RECURSE ...). However, when I compile, the compiler tries to 
compile the header files as if they were .cpp files, which leads to all 
kinds of strange results - from warnings about no public symbols for 
object file to linker errors about undefined external symbols for 
functions that are declared in a .h file, but implemented in a .cpp file.

It seems the root of the problem is that CMake adds them as source 
files, not as headers, but there must be another way to do it - probably 
we need to file a bug?

Cheers,
Thomas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080828/b8463dd2/attachment.htm>


More information about the CMake mailing list