[Insight-users] compile GaussianFilter outside InsightApplications-1.4

Luis Ibanez luis . ibanez at kitware . com
Fri, 05 Dec 2003 16:22:42 -0500


Hi George,

In order to extract the GaussianFilter example from InsightApplications
you must move out the following directories:

    InsightApplications/Auxiliary/FltkImageViewer
    InsithtApplications/GaussianFilter

The first directory contains a library of GUI Widgets that
are used by the GaussianFilter application.

You can build the FltkImageViewer library independently
by simply adding to its CMakeLists.txt file the following
lines:

IF(USE_FLTK)
  FIND_PACKAGE(FLTK)
  IF(FLTK_FOUND)
    INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIR})
  ENDIF(FLTK_FOUND)
ENDIF(USE_FLTK)


FIND_PACKAGE(ITK)
IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
  MESSAGE(FATAL_ERROR
          "Cannot build InsightApplications 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 InsightApplications without VTK.  Please set 
VTK_DIR.")
ENDIF(VTK_FOUND)



The same lines must be added to the CMakeLists.txt file
of the GaussianFilter directory.


Finally, in the CMakeLists.txt file of the GaussianFilter replace the 
top lines

INCLUDE_DIRECTORIES(
  ${InsightApplications_SOURCE_DIR}/Auxiliary/FltkImageViewer
  ${InsightApplications_BINARY_DIR}/Auxiliary/FltkImageViewer
  ${InsightApplications_SOURCE_DIR}/GaussianFilter
  ${InsightApplications_BINARY_DIR}/GaussianFilter
)

with

PROJECT( GaussianFilter )
INCLUDE_DIRECTORIES(
  ${FltkImageViewer_SOURCE_DIR}
  ${FltkImageViewer_BINARY_DIR}
  ${GaussianFilter_SOURCE_DIR}
  ${GaussianFilter_BINARY_DIR}
)

That should allow you to build the project independently of
InsightApplications.

You may want to look at the ITK tutorials in

    http://www . itk . org/HTML/Tutorials . htm

 In particular, number II, and V describe the
 integration of ITK, VTK and FLTK.



Please  let us know if you have any problems,


Thanks


  Luis


----------------------------------
george he wrote:

>Luis,
>
>Yes, I was trying to isolate the GaussianFilter so
>that I can build my own application based on it. Could
>you please let me know what else in the CMakeLists.txt
>I need to change? or do you suggest me to create a new
>sub-directory in the InsightApplications directory?
>
>Thanks,
>George
>
>
>--- Luis Ibanez <luis . ibanez at kitware . com> wrote:
>  
>
>>Hi George,
>>
>>You are not allowed to move the Binary nor the
>>Source
>>directories after your built is done.
>>
>>If you decided to change the location of the source
>>or the binary directories you must reconfigure with
>>CMake and rebuild the project.
>>
>>If what you want is to isolate one of the
>>applications
>>from the InsightApplications tree you must make a
>>number
>>of small modifications in the CMakeLists.txt file.
>>
>>
>>Please let us know if you have further questions.
>>
>>
>>Thanks
>>
>>
>>
>>     Luis
>>
>>
>>
>>-----------------
>>george he wrote:
>>
>>    
>>
>>>Hi,
>>>
>>>I was able to install ITK and FLTK successfully,
>>>and compile the InsightApplications-1.4 downloaded
>>>      
>>>
>>>from the web. But after I moved the directory
>>>InsightApplications-1.4/GaussianFilter to another
>>>location. I wasn't able to compile it anymore.
>>>Anybody knows what was wrong?
>>>
>>>I did try to combine the info from the
>>>      
>>>
>>CMakeLists.txt
>>    
>>
>>>files in the directories InsightApplications-1.4 
>>>and InsightApplications-1.4/GaussianFilter
>>>      
>>>
>>together.
>>    
>>
>>>Most error messages are like:
>>>
>>>In function `fltkImageViewerGUI::CreateGUI()':
>>>: undefined reference to
>>>`Fl_Value_Slider::Fl_Value_Slider[in-charge](int,
>>>      
>>>
>>int,
>>    
>>
>>>int, int, char const*)'
>>>
>>>In function `fltkImageViewerGUI::CreateGUI()':
>>>: undefined reference to
>>>      
>>>
>>`fl_define_FL_DIAMOND_BOX()'
>>    
>>
>>>In function
>>>      
>>>
>>`Fl_Menu_Bar::Fl_Menu_Bar[in-charge](int,
>>    
>>
>>>int, int, int, char const*)':
>>>: undefined reference to `vtable for Fl_Menu_Bar'
>>>
>>>Another question is, when I try
>>>FIND_PACKAGE(FltkImageViewer), why it was not
>>>      
>>>
>>found
>>    
>>
>>>even though the file FindFltkImageViewer.cmake is
>>>      
>>>
>>in
>>    
>>
>>>the directory ${InsightApplicationsDIR}?
>>>
>>>Thanks,
>>>George
>>>
>>>
>>>Here is my new CMakeLists.txt file:
>>>
>>>CMAKE_MINIMUM_REQUIRED(VERSION 1.6)
>>>PROJECT(GaussianFilter)
>>>INCLUDE_REGULAR_EXPRESSION("^.*$")
>>>
>>>SET(InsightApplicationsDIR
>>>$ENV{HOME}/src/InsightApplications-1.4)
>>>SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
>>>${InsightApplicationsDIR})
>>>MESSAGE("CMAKE_MODULE_PATH =
>>>      
>>>
>>${CMAKE_MODULE_PATH}")
>>    
>>
>>>SET(FltkImageViewerDIR
>>>
>>>      
>>>
>>${InsightApplicationsDIR}/Auxiliary/FltkImageViewer)
>>    
>>
>>># find ITK
>>>FIND_PACKAGE(ITK)
>>>IF(ITK_FOUND)
>>>  MESSAGE("ITK_USE_FILE = ${ITK_USE_FILE}")
>>>  INCLUDE(${ITK_USE_FILE})
>>>ELSE(ITK_FOUND)
>>>  MESSAGE(FATAL_ERROR "Cannot build GaussianFilter
>>>without ITK.  Please set ITK_DIR.")
>>>ENDIF(ITK_FOUND)
>>>
>>># find FltkImageViewer
>>>FIND_PACKAGE(FltkImageViewer)
>>>IF(FltkImageViewer_FOUND)
>>>  MESSAGE("FltkImageViewer_USE_FILE =
>>>${FltkImageViewer_USE_FILE}")
>>>  INCLUDE(${FltkImageViewer_USE_FILE})
>>>ELSE(FltkImageViewer_FOUND)
>>> 
>>>
>>>      
>>>
>INCLUDE($ENV{HOME}/src/InsightApplications-1.4/FindFltkImageViewer.cmake)
>  
>
>>>  # MESSAGE(FATAL_ERROR "Cannot build
>>>      
>>>
>>GaussianFilter
>>    
>>
>>>without FltkImageViewer.  Please set
>>>FltkImageViewer_DIR.")
>>>ENDIF(FltkImageViewer_FOUND)
>>>#
>>>
>>>      
>>>
>INCLUDE($ENV{HOME}/src/InsightApplications-1.4/FindFltkImageViewer.cmake)
>  
>
>>>INCLUDE_DIRECTORIES(${InsightApplicationsDIR}
>>>${FltkImageViewerDIR})
>>>
>>># find OpenGL
>>>FIND_PACKAGE(OpenGL)
>>>IF(OPENGL_INCLUDE_PATH)
>>> 
>>>
>>>      
>>>
>MESSAGE("OPENGL_INCLUDE_PATH=${OPENGL_INCLUDE_PATH}")
>  
>
>>>  INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_PATH})
>>>ENDIF(OPENGL_INCLUDE_PATH)
>>>
>>># find FLTK
>>>OPTION(USE_FLTK "Use FLTK for GUI" ON)
>>>IF(USE_FLTK)
>>>  FIND_PACKAGE(FLTK)
>>>  IF(FLTK_FOUND)
>>>    MESSAGE("FLTK FOUND. FLTK_INCLUDE_DIR =
>>>${FLTK_INCLUDE_DIR}")
>>>    INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIR}
>>>$ENV{HOME}/src/fltk-1.1.4/src)
>>>  ENDIF(FLTK_FOUND)
>>>  LINK_LIBRARIES (${FLTK_LIBRARIES})
>>>ENDIF(USE_FLTK)
>>>
>>>
>>>LINK_LIBRARIES (
>>>ITKAlgorithms
>>>ITKCommon
>>>ITKBasicFilters 
>>>)
>>>
>>># set include and lib directories for
>>>      
>>>
>>FltkImageViewer
>>    
>>
>>>MESSAGE("FltkImageViewerDIR =
>>>      
>>>
>>${FltkImageViewerDIR}.")
>>    
>>
>>>INCLUDE_DIRECTORIES(${FltkImageViewerDIR}
>>>${GaussianFilter_SOURCE_DIR}
>>>${GaussianFilter_BINARY_DIR})
>>>LINK_DIRECTORIES(${FltkImageViewerDIR})
>>>
>>>SET(GaussianFilter_SRCS 
>>>  liFilterConsole.cxx
>>>  liFilterConsoleBase.cxx 
>>>  GaussianFilter.cxx
>>>  )
>>>
>>>SET(GaussianFilter2D_SRCS 
>>>  liFilterConsole2D.cxx
>>>  liFilterConsole2DBase.cxx 
>>>  GaussianFilter2D.cxx
>>>  )
>>>
>>>MACRO(ADD_GUI_EXECUTABLE name sources)
>>>  ADD_EXECUTABLE(${name} ${sources})
>>>ENDMACRO(ADD_GUI_EXECUTABLE)
>>>
>>>MACRO(ITK_DISABLE_FLTK_GENERATED_WARNINGS files)
>>>  IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}
>>>GREATER 1.6)
>>>    IF(CMAKE_COMPILER_IS_GNUCXX)
>>>      FOREACH(f ${files})
>>>        STRING(REGEX REPLACE "\\.fl$" ".cxx" SRC
>>>"${f}")
>>>        STRING(REGEX REPLACE ".*/([^/]*)$" "\\1"
>>>      
>>>
>>SRC
>>    
>>
>>>"${SRC}")
>>>        SET_SOURCE_FILES_PROPERTIES(${SRC}
>>>      
>>>
>>PROPERTIES
>>    
>>
>>>COMPILE_FLAGS -w)
>>>      ENDFOREACH(f)
>>>    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
>>> 
>>>      
>>>
>>ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}
>>    
>>
>>>GREATER 1.6)
>>>ENDMACRO(ITK_DISABLE_FLTK_GENERATED_WARNINGS)
>>>
>>>ADD_GUI_EXECUTABLE(GaussianFilter  
>>>"${GaussianFilter_SRCS}")
>>>ADD_GUI_EXECUTABLE(GaussianFilter2D
>>>"${GaussianFilter2D_SRCS}")
>>>      
>>>
>=== message truncated ===
>
>
>__________________________________
>Do you Yahoo!?
>Free Pop-Up Blocker - Get it now
>http://companion . yahoo . com/
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk . org
>http://www . itk . org/mailman/listinfo/insight-users
>
>  
>