[CMake] template files (.t) in Windows VCproj builds

Philip Lowman philip at yhbt.com
Tue Sep 19 12:33:59 EDT 2006


Hi,

I'm experimenting with CMake (2.4 patch 3) and noticed a couple of
peculiar things with template files and the Windows Vcproj files I was 
curious about.

I have a collection of libraries all being built in separate directories
with the ADD_LIBRARY() directive.  I started off with just having my .cc
files in my ADD_LIBRARY() command.  As a convenience for developers
however, I wanted to get header files and template files to be included
in the VCproj files so that people can double click on them to open them 
(like they do now).

1.) [minor] After adding all of my header files (.h) and template files
(.t) to the ADD_LIBRARY command I noticed that the header files were
being placed in a separate folder called "Header Files" in the VC
Projects.  Cool.  Unfortunately, however, the template files were not
being placed in this same folder, they were simply being included in the
toplevel folder.  Futhermore...

2.) [major] It seems that Visual Studio is trying to compile about half
of the template files that I add to my ADD_LIBRARY() directive (it's
treating them as source files).  Is there any reason why anyone would 
ever want to compile a ".t" file (C++ template)?  Also I'm curious why 
there is a difference in behavior with half of the template files 
treated as headers and the other half treated as sources.

3.) [minor] I tried to use the SOURCE_GROUP() command to try to force
the header and template files into the "Header Files" group although I
discovered from a previous post on this list that this nifty looking
command only seems to work if you're making an executable (after trying
to get it to work but not having any luck).  It would be nice for this
command to support ADD_LIBRARY() as well although I don't know the
details of how feasible this is.

I used the SET_SOURCE_FILES_PROPERTIES() directive to mark the template
files that Visual Studio was trying to compile explicitly as header
files and that seemed to be an ok workaround for problem #2.

I noticed that there is already a bug in the tracker for my first issue
(#1) but the suggested workaround is to use SOURCE_GROUP (which isn't
useable with ADD_LIBRARY?) or ADD_CUSTOM_TARGET.  I'm not sure how to 
use ADD_CUSTOM_TARGET for this purpose and would appreciate any advice 
on the matter.
http://www.cmake.org/Bug/bug.php?op=show&bugid=1493&pos=5

I was just wondering if anyone had any insight into any of these
problems or any suggestions.

Thanks

-- 
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com




More information about the CMake mailing list