[CMake] SOURCE_GROUP in VS005

Hicham Mouline hicham at mouline.org
Fri Mar 27 07:22:39 EDT 2009


> -----Original Message-----
> From: Mattias Helsing [mailto:helsing72 at gmail.com]
> Sent: 27 March 2009 10:45
> To: Hicham Mouline
> Subject: Re: [CMake] SOURCE_GROUP in VS005
> 
> Hi Hicham,
> 
> You need to point out files explicitly like:
> source_group("Header Files\\subdir1" FILES
>   subdir1/file2.hpp
>   subdir1/file3.hpp
> )
> 
> You could do:
> in lib1/subdir1/CMakeLists.txt
> set(SUBDIR1_HEADER_FILES
>   subdir1/file2.hpp
>   subdir1/file2.hpp
>   PARENT_SCOPE
> )
> 
> ...which is a bit hacky since you need to name subdir1 (which you are
> currently in) for it to work on the level above (parent scope)
> 
> and then in lib1/CMakeLists.txt
> add_subdirectory(subdir1)
> add_subdirectory(subdir2)
> 
> source_group("Header Files\\subdir1" FILES  ${SUBDIR1_HEADER_FILES})
> source_group("Header Files\\subdir2" FILES  ${SUBDIR2_HEADER_FILES})
> 
> add_library(lib1
>   File1.cpp file1.hpp
>   ${SUBDIR1_HEADER_FILES}
>   ${SUBDIR2_HEADER_FILES}
> )
> 
> above completely untested from the tips of my fingers
> 
> cheers
> Mattias
> 
> 
> On 3/27/09, Hicham Mouline <hicham at mouline.org> wrote:
> > Hello,
> >
> > I have the following source dir structure
> >
> > lib1\CMakeLists.txt
> > lib1\file1.cpp
> > lib1\file1.hpp
> > lib1\subdir1\CMakeLists.txt
> > lib1\subdir1\file2.hpp
> > lib1\subdir1\file3.hpp
> > lib1\subdir2\CMakeLists.txt
> > lib1\subdir2\file4.hpp
> > lib1\subdir2\file5.hpp
> > ...
> >
> >
> > I wish to see this in VS2005
> >
> > ...
> > + lib1 (project)
> >   + Header files
> >      file1.hpp
> >      +subdir1
> >        file2.hpp
> >        file3.hpp
> >        CMakeLists.txt
> >      +subdir2
> >        file4.hpp
> >        file5.hpp
> >        CMakeLists.txt
> >   + Source files
> >      file1.cpp
> >   CMakeLists.txt
> > ...
> >
> > SO I tried this
> >
> > =========== lib1\CMakeLists.txt================
> > ADD_SUBDIRECTORY(subdir1)
> > ADD_SUBDIRECTORY(subdir2)
> >
> > ADD_LIBRARY(lib1
> >    File1.cpp file1.hpp
> > ######### Can I report the inclusion of subdir? header files
> > ######### to the subdir? cmake files
> >
> > =========== lib1\CMakeLists.txt================
> > SOURCE_GROUP(....
> >    File2.hpp
> >     File3.hpp
> > )
> >
> > Rds,
> >
Perfect, it works.
Thanks very much.



More information about the CMake mailing list