[Insight-users] Using ITK externally
Neil Killeen
Neil.Killeen@atnf.csiro.au
Thu, 12 Dec 2002 18:13:20 +1100 (EST)
G'day all
I am now attempting to include ITK (and VTK for that matter)
in an external project. I am finding this process less than clear...
1) I have installed ITK as
/usr/local/lib/itk
/usr/local/include/itk
However, I installed these files by copying them from where
the ITK install process
% make install
put them. This is because it put them somewhere silly (under the
vtk build tree in fact) because i did not get control over
the itk install location. I posted a message about this a few days
ago.
2) The ITK include tree is hierarchical in /usr/local/include
thus
% ls /usr/local/include/itk/
Algorithms Common Numerics Utilities
BasicFilters IO SpatialObject itkConfigure.h
However, none of the ITK source tree code reflects this.
ITK .h files are just included with no directory prefix, whether
they live in Algorithms or Utilities or wherever.
This is handled by specifying multiple locations to find the
include files via the cmake command
SET(ITK_INCLUDE_DIRS ...)
3) Clearly I don't want to have to hard-code all of the include
directories.I am tempted to just move all of the nested files into
/usr/local/include/itk
and that will be that. However, I realize that there is a file,
ITKConfig.cmake.in
which I am supposed to include in my own CMakeLists.txt file
to configure ITK for me.
But I can't understand the philosophy nor make it work. I have to do
something like this in my CMakeLists.txt file in my own project source
tree:
# Configure ITK
SET (ITK_DIR /nfs/source/itk) # Tell it where to find ITK source tree
INCLUDE(${ITK_DIR}/ITKConfig.cmake.in) # Invoke configure
INCLUDE_DIRECTORIES(${ITK_INCLUDE_DIRS}) # Set include directories
But this does not and cannot work. This is because it has no way of
knowing where I have installed the ITK system. I did that by hand
(see 1) above).
4) I don't actually see how the statement
INCLUDE(${ITK_DIR}/ITKConfig.cmake.in) # Invoke ITK configure
could ever work, becuase the install location is in the cmake Cache
file in the binary tree, not anywhere in the source tree.
Now I realize that when I invoke, say
% ccmake $ITKSRC
that this defines variables locating the directory from which
I am running cmake (the PROJECT_BINARY_DIR variable) so that cmake
does know the present binary tree location (so that it can output
the binaries to the right place).
However, I am running cmake now to build MY system, not ITK or VTK
or whatever, so it can compute PROJECT_BINARY_DIR for my project.
But it can't possibly compute it for when ITK was built since that
information is not cached in the ITK source tree which it is accessing.
So how can ITKConfig.cmake.in ever compute ITK_BINARY_DIR or
ITK_INSTALL_DIR (if there was one) when I am building my project.
Perhaps there is something simple I am just failing to understand.
I hope so :-)
Questions:
1) Why are the ITK include files installed hierarchically, when they
are never invoked that way in the source code ? I notice that
VTK include files are just dumped in one directory. Then its
trivial to include /usr/local/include/vtk in the directory path.
ALso, the ITK libraries are not installed hieararchically, so it is
in fact easy for me to specify the linker directory as
/usr/local/lib/itk
2) How do I automatically determine the ITK include directories when
i have installed them as I did (above) ?
3) In many of the install include directories, there are files with
.txx extensions. What are they ? They hold C++ code.
thanks again
Neil