[CMake] How to preserve directory structure within Visual Studio

Stephen Torri stephen.torri at gmail.com
Thu Dec 8 15:32:52 EST 2011


CMake version: 2.8
IDE: Visual Studio 2008

For the source and header files I would like to preserve the directory
structure within the Visual Studio "Header Files" and "Source Files"
folders. Without it should there occur two files with the same name
but in different directories only one is shown. For example:

SET ( HEADERS
   base_units/time.hpp
   si/time.hpp )

add_custom_target ( UnitHeaders SOURCES ${HEADERS} )

If UnitHeaders is included within the parent CMakeLists.txt file a
Project called UnitHeaders is included within the Visual Studio
Solution. What you will see undert the "Header Files" for UnitHeaders
is only one header file. I would like to see the following within
Visual Studio under Header Files:

UnitHeaders
   |
   |-- Header Files -> base -> time.hpp
                          -> si -> time.hpp

A search on Google has shown two similar questions asked in the past
but no answer was posted in reply to them.

Stephen


More information about the CMake mailing list