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

BRM bm_witness at yahoo.com
Thu Aug 28 10:09:51 EDT 2008


Question:

What about those of us that do not want the header files compiled (no pre-compiled headers, etc.), but still want the folders to show up in Visual Studio (or any other IDE)?
Personally, I think that having to add them as 'source' when they are explicitly _not_ source but definitions is the wrong thing. I love CMake; but not having them listed unless I put them in as source leads to productivity issues too - since I now have to remember which files the headers were included in, find the include line, and open the file from there.

Why not having a simple add_headers() function for the project too? That would solve the problem for any IDE, and make things cleaner in the projects too; as well as give the user the option of pre-compiled vs. no pre-compiled headers. (And in case you're wondering, I am not a fan of pre-compiled headers by any measure; I rather try to avoid them.)

Ben



----- Original Message ----
From: Thomas T. <cmake.org at thomas.traenkler.com>
To: CMake Mailinglist <cmake at cmake.org>
Sent: Wednesday, August 27, 2008 7:10:52 PM
Subject: [CMake] Bug? Broken header files in Visual C++ 2008 project


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/e50df95c/attachment.htm>


More information about the CMake mailing list