[CMake] SOURCE_GROUPS

William A. Hoffman billlist at nycap.rr.com
Wed May 17 08:33:26 EDT 2006


At 06:44 AM 5/17/2006, Manuel Klimek wrote:
>Hi there,
>
>I've got a problem with SOURCE_GROUPS with cmake 2.4.1 in windows (VC 2005).
>I already found out that if I want to add headers in a source
>group I'll have to add the headers to the ADD_LIBRARY or ADD_EXECUTABLE.
>But I have the problem that I include platform specific .cpp files
>in another .cpp file and I want to add those files to the source list.
>I don't know how I can make them show up in the source group without
>compiling the file:
># x.cpp includes x_inc.cpp
>SET( x_SRC x.cpp )
>SET( x_HDR x.h )
>SET( x_INC x_inc.cpp )
>SOURCE_GROUP( "X Sources" ${x_SRC} ${x_INC} )
>SOURCE_GROUP( "X Headers" ${x_HDR} )
>ADD_LIBRARY( x STATIC ${x_SRC} ${x_HDR} ${x_INC} )
>
>now it tries to compile x_inc.cpp which doesn't work
>because it only compiles when included in x.cpp
>
>I already tried:
>SET_SOURCE_FILES_PROPERTIES( x_inc.cpp HEADER_FILE_ONLY 1 )
>but that didn't change anything
>
>if I do simply
>ADD_LIBRARY( x STATIC ${x_SRC} ${x_HDR} )
>the x_inc.cpp doesn't show up at all ...
>
>I though about somehow adding a dependency from library x to
>x_inc.cpp but couldn't find out how to do this either...

Currently there is no way to do this.   If you want you can put in
a feature request.  I guess if all the generators looked at HEADER_FILE_ONLY
and did not compile files that had that property it would work.  I think
you can set some property on a vs file to make the ide not compile it.

-Bill



More information about the CMake mailing list