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

Brad King brad.king at kitware.com
Tue Sep 19 13:13:20 EDT 2006


Philip Lowman wrote:
> 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...

The SOURCE_GROUP command just maps source files to folders for projects
in which they are already used.  You have to list all the sources
(headers, template files, etc.) in the target.  Then use SOURCE_GROUP to
map specific file patterns to specific groups.  The generated project
for each target using a source file will put the source file under the
group specified by SOURCE_GROUP.

> 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.

If they have the same name as a .h or .cc file there is a bug in CMake
2.4.3 that causes this.  The work around is to add the HEADER_FILE_ONLY
property with SET_SOURCE_FILES_PROPERTIES.  It is fixed in CVS CMake and
will be fixed in 2.4.4.

> 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'm not familiar with this constraint.  Please post a small example
CMakeLists.txt file that reproduces the problem.  The following works
for me:

SOURCE_GROUP(FooFiles FILES foo.cxx)
ADD_LIBRARY(foo foo.cxx)

-Brad


More information about the CMake mailing list