[Cmake] Idea for an addition to CMake

Blezek, Daniel J (Research) blezek at crd.ge.com
Thu Jan 16 08:56:37 EST 2003


All,

  I was writing a CMakeLists.txt file over the past two days, and found myself repeating a lot of
code to do simple things, where only a filename changed.  Would adding a macro/procedure command be
feasable?  I could see something like this:

<From VTK/Imaging/CMakeLists.txt, repeated elsewhere>

# if we are wrapping into Tcl then add the library and extra
# source files
#
IF (VTK_WRAP_TCL)
  VTK_WRAP_TCL(vtkImagingTCL ImagingTCL_SRCS ${Imaging_SRCS})
  ADD_LIBRARY(vtkImagingTCL ${ImagingTCL_SRCS})
  TARGET_LINK_LIBRARIES (vtkImagingTCL
                         vtkFilteringTCL
                         vtkImaging
                         ${TCL_LIBRARY})
  INSTALL_TARGETS(/lib/vtk vtkImagingTCL)
ENDIF (VTK_WRAP_TCL)


# Macro definition
DEFINE_MACRO(WrapTcl)
IF (VTK_WRAP_TCL)
  VTK_WRAP_TCL(vtk${1}TCL ${1}TCL_SRCS ${2})
  ADD_LIBRARY(vtkImagingTCL ${${1}TCL_SRCS})
  TARGET_LINK_LIBRARIES (vtk${1}TCL
                         ${3})
  INSTALL_TARGETS(/lib/vtk vtk${1}TCL)
ENDIF (VTK_WRAP_TCL)
ENDDEFINE_MACRO(WrapTcl)


# Usage
MACRO(WrapTcl Imaging ${Imaging_SRCS} "vtkFilteringTCL vtkImaging ${TCL_LIBRARY}" )

Inside the macro, only the ${1}, ${2}, ${3} variables would be expanded, everything else is verbatum
output, and is given to the CMake parser.  This would greatly simplify many repeated processes, and
something like UseVTK.cmake could define some very useful macros.

-dan

--
Daniel Blezek, Ph.D.
blezek at crd.ge.com
Visualization and Computer Vision Lab, Imaging Technologies
GE Global Research Center



More information about the CMake mailing list