[Insight-users] Using ITK externally

Luis Ibanez luis.ibanez@kitware.com
Mon, 16 Dec 2002 10:00:48 -0500


Hi Neil,

Thanks for your comments on the building process.

A) About the build/install process:

   We are trying to further separate the demo-applications
   from the actual ITK code. As you just noticed, having
   the demo-application inside the ITK source tree leads
   to confusion and sometimes encovers errors like missing
   libraries on the link line.

   We should probably have two separate build steps.
   One for building just ITK, which comes down to the
   "Code" directory. The built libraries and the headers
   should be installed. This build process will not require
   any of the external libraries (FLTK, VTK, OpenGL, GLUT...)
   since ITK does not depend on them.

   Then, a second pass in which the demo-applications and
   the testing are built using the installed ITK. Here is
   where external libraries will be needed, e.g. for supporting
   GUI and visualization.

   This is something Brad has been insisting on for some
   time but we haven't paid enough attention...


B) About the missing X11 libraries

   X11 libraries are included directly by FindFLTK.cmake.
   They should be in the link line of all the projects that
   do include this CMake Module.

   I wonder is this problem (of missing X11 libs) may be due
   to your version of CMake. Could you please take a look at
   the CMake/Modules/FindFLTK.cmake file and check if the
   following lines are in there:

> IF(UNIX)
>   SET( FLTK_PLATFORM_DEPENDENT_LIBS ${CMAKE_X_LIBS}  -lm)
> ENDIF(UNIX)

   and

>   SET( FLTK_LIBRARIES ${FLTK_BASE_LIBRARY} ${FLTK_GL_LIBRARY}
>     ${FLTK_FORMS_LIBRARY}  ${FLTK_IMAGES_LIBRARY} ${FLTK_PLATFORM_DEPENDENT_LIBS}
>   )

   These lines set the "platform dependent" libraries for FLTK.
   In windows they set wsock32 and comctl32. On Unix this set
   the X11 libs as defined in the variable CMAKE_X_LIBS and the
   math library "libm".

   Please let us know what you find.


C) About the need of running CMake from the binary tree
    instead of the source tree. The reason is (as you
    already guessed) related with the need of building
    diferent binary configurations by sharing the same
    source tree.  you may notice for example that in
    the dashboard there are machines building for:

    - Borland 5.5
    - Visual Studio 7
    - Visual Studio 6

    by sharing the same source tree.
    The same happens in Linux where we build for gcc2.96,
    gcc 3.02 and gcc3.2 in the same machine.

    This versatility would have been impossible if CMake
    stored the configuration on the source tree.


D) About regenerating only a subset of Makefiles with
    CMake. This is actually pretty easy.

    Just go to the binary directory associated with the
    source subdirectory that you modified.  Let's say
    that you made a change in

    Insight/Testing/Code/BasicFilters

    well,
    then you have to go tho the binary image dir

    InsightDir/Testing/Code/BasicFilters
    and simply type:

    make

    the Makefile should notice that the CMakeLists.txt
    file has been updated and because this file is in
    the dependencies it will invoke "cmake" and regenerate
    the Makefile. In some cases you may have to type

    make depend

    before running "make",
    but in general just "make" should be enough.

    Please give it a try and let us know if this
    behaves differently. (in which case, there may be
    something we have to fix).



Thanks a lot for your feedback,


   Luis

---------------------------------------------------

Neil Killeen wrote:
> ok; on eradicating VTK (which I included as my own project will use
> both itk and vtk), indeed I got control over the install path. so that
> worked ok now.
> 
> I found after doing this, that some of the Examples no longer
> linked as they were missing X11 in the link list.  MetaImageViewer for
> example, I think (does not use VTK).
> 
> It seems as there is some mis-configuration when VTK is not included
> but Tcl is, such that X11 is not linked in.
> 
> I was not able to divine where X11 was added in the process, despite
> a lot of poking about.    When I added X11 by hand, they linked OK.
> 
> 
> 
> 
> 
>>Read Insight/Documentation/InsightStart.pdf from the source tree.  It
>>includes information on how to use ITK from your project.  Here is a quick
>>start if you don't want to use FindITK.cmake:
>>
>>
> 
> I did (squeaky voice) !   OK, now that I know that the config file
> lives in the installed library path, I can understand the process now
> and I have managed to link an application in my own project tree
> with ITK.  Yay me.
> 
> ----
> 
> 
> I have a couple of philosphical questions about the organization of the
> building process
> 
> The way ITK is set up with cmake, you do
> 
> . install code
> . create binary location directory
> . run cmake from the binary tree
> 
> That is, you position yourself in the binary tree to build modules and
> applications.    I  have copied this style for my own project.
> 
> 1) I would usually choose to arrange things so that I position myself
>   in the *code* tree when building modules or applications.  The system
>   should know what platform I am using (it can figure it out) and set the
>   build location appropriately and send the output there.  In this way, I
>   don't have to hop from code location to build location as I build code.
> 
>   Is it something to do with the cross-platform nature of cmake that
>   pushed the design in the other direction ?   Can cmake be used the other
>   way around ?
> 
> 2) When I change a piece of the source tree (e.g. add a new module,
>    or decide I need a new link list etc) I must regenerate the entire
>    binary tree set of makefiles ('g' in cmake).    Is there a way to ask
>    the system to just regenerate a piece of the tree ?   It might be rather time
>    consuming  to do the former for large projects.   Again, this comes
>    down to the philosophy alluded to in 1) above, I think.
> 
> 
> 
> thanks for your (plural) continued help
> 
> cheers
> Neil
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>