[Insight-users] Simple CMakeList.txt

Brad King brad.king@kitware.com
Wed, 6 Nov 2002 09:37:03 -0500 (EST)


Mathieu,

> INCLUDE (${CMAKE_ROOT}/Modules/FindITK.cmake)
> IF (  USE_ITK_FILE  )
>           INCLUDE(  ${USE_ITK_FILE}  )
> ENDIF(   USE_ITK_FILE   )

This is all you need to use ITK, the ITK_DIR stuff is the alternative.
You can use the lines below INSTEAD of (not with) the lines above.  The
difference is that the code below will support using ITK from an
installation tree separate from the build tree.

# This part will be most of the implementation of the FindITK.cmake module
# in the next version of CMake.
FIND_PATH(ITK_DIR ITKConfig.cmake)
IF(ITK_DIR)
  INCLUDE(${ITK_DIR}/ITKConfig.cmake)
  SET(ITK_FOUND 1)
ELSE(ITK_DIR)
  MESSAGE("ITK not found.  Set ITK_DIR to the location of ITKConfig.cmake.")
ENDIF(ITK_DIR)

# This part actually brings in the include directories, link
# directories, and preprocessor definitions needed to use ITK.
# One may optionally write INSTEAD the
#   INCLUDE_DIRECTORIES(${ITK_INCLUDE_DIRS})
#   LINK_DIRECTORIES(${ITK_LIBRARY_DIRS})
#   ADD_DEFINITIONS(${ITK_DEFINITIONS})
# lines by hand to get more fine-grained control, but it will not
# automatically enforce that your compiler matches ITK's compiler.
IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ENDIF(ITK_FOUND)

> INCLUDE (${CMAKE_ROOT}/Modules/FindFLTK.cmake)
> IF (   USE_FLTK_FILE   )
>           INCLUDE(  ${USE_FLTK_FILE}  )
> ENDIF(   USE_FLTK_FILE   )

This should be simply

  INCLUDE (${CMAKE_ROOT}/Modules/FindFLTK.cmake)

because there is no "use" file for FLTK.  It is not a CMake project.

> TARGET_LINK_LIBRARIES((Echolyse2-exe ${ITK_LIBRARIES})
>
> ADD_EXECUTABLE(Echolyse2-exe Echolyse_SRCS)
>
> FLTK_WRAP_UI(Echolyse2-exe Echolyse_GUI_SRCS)

TARGET_LINK_LIBRARIES needs to be after the ADD_EXECUTABLE because the
target must exist before it can be told how to link.  These lines should
be:

ADD_EXECUTABLE(Echolyse2-exe ${Echolyse_SRCS})
TARGET_LINK_LIBRARIES(Echolyse2-exe ${ITK_LIBRARIES})
FLTK_WRAP_UI(Echolyse2-exe ${Echolyse_GUI_SRCS})

or, if you know specifically what ITK libraries you want, you can use a
command like

TARGET_LINK_LIBRARIES(Echolyse2-exe ITKCommon ITKAlgorithms)

Sorry for all the confusion in the build process.  ITK and CMake have been
under very rapid development.

-Brad