[CMake] Include subdirectories

Tyler Roscoe tyler at cryptio.net
Thu Feb 25 16:45:54 EST 2010


On Thu, Feb 25, 2010 at 09:56:24PM +0100, Christian Werner wrote:
> I am sure this has been asked before, but somehow I don't find a place 
> where I can easily browse the mailing list postings (I just found that 
> link where you can browse isolated months). I am writing plugins for 

Yeah I just noticed that google used to turn up cmake.org/pipermail
links but now is returning article.gmane.org links. I agree that the
gmane.org archives are difficult to navigate.

> ParaView and I want to know how I can make cmake recursively search all 
> subdirectories for included .h files. For example I have:
> 
> INCLUDE_DIRECTORIES(
>    ${PV_PLUGIN_DIR}/Filter
>    ${PV_PLUGIN_DIR}/Segmentation
>    ${PV_PLUGIN_DIR}/Transformation
>    ${PV_PLUGIN_DIR}/vtk2itk2vtk
> )
> 
> But all these directories contain no .h file. Instead they consist of 
> subdirectories, each containing their own .h files. For every Paraview 
> Plugin I write there will be a new subdirectory, e.g.
> 
>    ${PV_PLUGIN_DIR}/Segmentation/DisDyn
> 
> It would be nice if I wasn't forced to enter every new directory into 
> some CMakelist.

Yes, this is deliberate. CMake wants you to specify all the include dirs
so that when you add one (or remove one), CMake can notice that your
project has changed and regenerate your build files for you. It's the
same reason CMake wants you to specify the names of all your source
files, instead of just compiling *.cpp.

You could hack around this with file(GLOB) or something else, but I
don't recommend it. Just maintain all the include dirs into your
CMakeLists.txt; it's not that hard and in exchange you get a more
reliable build process.

tyler


More information about the CMake mailing list