AW: [CMake] Visual Studio 2005: Make header files withoutcorresponding source files viewable in the solution explorer

Kolloch, Peter Peter.Kolloch at norcom.de
Mon Dec 3 04:37:41 EST 2007


Thanks a lot for your ideas! It's a bit awkward that non-test header files end up in your test sub projects. Too bad that this is not easily implemented in a more straight-forward fashion. 

Maybe I experiment with custom targets or something similar (or give up ;).

-----Ursprüngliche Nachricht-----
Von: cmake-bounces+peter.kolloch=norcom.de at cmake.org [mailto:cmake-bounces+peter.kolloch=norcom.de at cmake.org] Im Auftrag von Marcus
Gesendet: Freitag, 30. November 2007 22:55
An: cmake at cmake.org
Betreff: Re: [CMake] Visual Studio 2005: Make header files withoutcorresponding source files viewable in the solution explorer

Dear Peter,  (sorry if you receive two copies of this)

> I have some header files containing only template code which I would 
> like to see in the solution explorer. They are not logically associated 
> with any libraries or executables in my project.

I am also new to CMake, but as I understand it, the only way to do this
is to associate the files with some sort of build target or action.
This is a limitation of Visual Studio, rather than CMake.

The way I have solved this is to create a unit test suite to accompany
each of my libraries, and I compile a separate 'test runner' executable
for every suite.  This means that when my library consists only of
header files, I can associate the headers with the corresponding test
runner.  The headers will then appear as a 'test project' in Visual Studio.

For example, when I build a shared library, I will have two projects in
Visual Studio:

MySharedLibrary <- This project compiles the dll, and includes all of
the source files

MySharedLibrary_TEST <- This project compiles the test runner, and
contains only test code


But when my library consists only of header files, I will see a single
test project in Visual Studio:

MyHeaderLibrary_TEST <- This project compiles the test runner, and
contains both the library's header files and the test code.


> I would also like to 
> simply link to some Perl test scripts in the solution explorer in their 
> own project or so.

I recommend looking at ADD_CUSTOM_COMMAND or ADD_CUSTOM_TARGET.

Marcus
_______________________________________________
CMake mailing list
CMake at cmake.org
http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list