AW: [Insight-users] How to write CMakeLists

jiang jiang at TI . Uni-Trier . DE
Tue, 23 Sep 2003 17:08:01 +0200


Thanks! It works fine.

-----Ursprungliche Nachricht-----
Von: Gavin Baker [mailto:gavinb+xtk at cs . mu . OZ . AU]
Gesendet: Dienstag, 23. September 2003 03:50
An: jiang
Betreff: Re: [Insight-users] How to write CMakeLists



Hello Chunyan,

On Mon, Sep 22, 2003 at 06:31:28PM +0200, jiang wrote:

> If I want to use VTK as visualization tool, how can I add this library to
> CMakeLists? I wrote it as
> LINK_LIBRARIES (
> ${ITK_LIBRARIES}
> ${VTK_LIBRARIES}
> )

You first need to call FIND_PACKAGE() which sets up these variables, as well
as a bunch of other settings.  The CMake guide has more info on this:

    http://www . cmake . org/HTML/Documentation . html

> I install vtk42 in my system.
> However it does not work. The program can not pass compiling. The error
> message is:
> fatal error C1083: Cannot open include file: 'vtkRenderWindow.h': No such
> file or directory...

This is just because the include path is not set; using FIND_PACKAGE() will
fix this by setting include and lib paths.

Here is a working example from a simple appliation of mine:



PROJECT(vgf)

# Required libraries

FIND_PACKAGE(ITK)
IF(ITK_FOUND)
   INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
   MESSAGE(FATAL_ERROR "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)

FIND_PACKAGE(VTK)
IF (VTK_FOUND)
   INCLUDE(${VTK_USE_FILE})
ELSE(VTK_FOUND)
   MESSAGE(FATAL_ERROR "Cannot build without ITK.  Please set VTK_DIR.")
ENDIF(VTK_FOUND)

# The application

ADD_EXECUTABLE(vgf vgf.cxx)

TARGET_LINK_LIBRARIES(vgf popt ITKCommon ITKIO ITKBasicFilters vtkCommon
vtkImaging vtkGraphics vtkIO vtkFiltering vtkHybrid vtkRendering)



The libraries are specified individually so as not to include every one, but
you could use ${VTK_LIBRARIES} if you wish.

Hope this helps...

  :: Gavin

--
Gavin Baker                                Computer Vision Lab (CVMIL)
http://www . cs . mu . oz . au/~gavinb                 University of Melbourne