[vtk-developers] LocalUserOptions and CMakelists.txt

John Biddiscombe john.biddiscombe at mirada-solutions.com
Thu May 15 09:20:51 EDT 2003

I frequently get conflicts in my CMakelists.txt files caused by the fact that I have two includes of LocalUserOptions files for each kit. This is primarily because I've customized my wrapping process somewhat and want one set of local rules executed before the WRAP_TCL etc commands and one after (when the kit_TCL variables etc are valid). I realized the other day that with Macros, one could do the following

for each cmakelists.txt in common/filtering/imaging etc etc

# Allow the user to customize their build with some local options
INCLUDE (${VTK_BINARY_DIR}/${KIT}/LocalUserOptions.cmake OPTIONAL)
INCLUDE (${VTK_SOURCE_DIR}/${KIT}/LocalUserOptions.cmake OPTIONAL)

and after the wrapping commands have done their stuff

# If the user defined a custom macro, execute it now and pass in all the srcs
  LocalUserOptionsMacro( "${Kit_SRCS}"       "${Kit_EXTRA_SRCS}"
                         "${KitTCL_SRCS}"    "${Kit_TCL_EXTRA_SRCS}"
                         "${KitJava_SRCS}"   "${Kit_JAVA_EXTRA_SRCS}"
                         "${KitPython_SRCS}" "${Kit_PYTHON_EXTRA_SRCS}")

# End of common section
# -----------------------------------------------------------------

with the LocalUserOptions.cmake file defining something like
MACRO( LocalUserOptionsMacro 
           kit_SRCS        kit_EXTRA_SRCS 
           kit_TCL_SRCS    kit_TCL_EXTRA_SRCS 
           kit_JAVA_SRCS   kit_JAVA_EXTRA_SRCS 
# Put user code in here to do things with the lists

ENDMACRO( LocalUserOptionsMacro )

I've tried this out on my local build and it's lovely. I wish I'd thought of this a long time ago and I'm going to commit it to cvs unless anyone can
a) object
b) suggest improvements
c) thinks that the list of params to the local user macro should be different so that more people can take advantage of it.



More information about the vtk-developers mailing list