[CMake] Headers listing in Visual Studio

Eric Noulard eric.noulard at gmail.com
Wed Oct 3 16:48:02 EDT 2007


2007/10/3, Félix C. Morency <felix.morency at gmail.com>:
> Hi,
>
> I would like to know how to list the header files in the header directory in
> the visual studio IDE. Actually, only the sources and cmake-related files
> are listed. I want to be able to see the headers as well (cosmetic reasons).
> I searched in the doc and on the net and found nothing. I tried with
> ADD_CUSTOM_COMMAND( OUTPUT ${PROJECT_NAME} MAIN_DEPENDENCY ${PROJ_HDRS} )
> but only the last header file listed in ${PROJ_HDRS} appears in the IDE.
> Could someone help please ?

I think that if you add header files in your

ADD_LIBRARY
and
ADD_EXECUTABLE
command the header will show up in Visual Studio

aka instead of

ADD_LIBRARY(MyLib file1.c file2.c)
put
ADD_LIBRARY(MyLib file1.c file2.c file1.h file2.h)

the same is true for other kind of header files like .hh .hxx and the like.
they won't be "compiled" but added to you "browsable files".

you may have a look at
SOURCE_GROUP macro which may be useful too.

>
> Also, could we do the same thing with generated MOC files (QT4) ?

I don't know for that kind of file I do not use it currently.

-- 
Erk


More information about the CMake mailing list