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

Greg Peele gpeele at ara.com
Wed Aug 27 19:18:55 EDT 2008


Thomas,

I don't know how helpful saying this will be, but it works for me, at
least for CMake 2.6.1 and VS 2008 Express.  My same project also builds
unchanged for 2005 Professional and 2003 Professional, and the headers
even end up in the right project folders by default (I don't use source
group or any globbing though).  Could you provide an example of how
you're using add_library or add_executable?

Greg Peele
Applied Research Associates, Inc.

On Thu, 2008-08-28 at 01:10 +0200, Thomas T. wrote:
> 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 
> 
> 
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list