[Cmake] Idea for an addition to CMake

Andy Cedilnik andy.cedilnik at kitware.com
Thu Jan 16 11:58:10 EST 2003


Hi Dan,

CMake 1.6 has macros. The syntx is a bit different than what you
sugested:

MACRO(FOO BAR)
  MESSAGE("Bar: ${BAR}")
ENDMACRO(FOO)

BAR("Andy")

Will do what you want.

			Andy

On Thu, 2003-01-16 at 08:56, Blezek, Daniel J (Research) wrote:
> 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
> _______________________________________________
> Cmake mailing list
> Cmake at public.kitware.com
> http://public.kitware.com/mailman/listinfo/cmake




More information about the CMake mailing list