Commit a9a87512 authored by Brad King's avatar Brad King

Declare a "TCL_NAME" for modules named with digits

Tcl does not support packages with digits in their names.  We map module
names containing digits to alternative names for Tcl packages.
Generalize the existing hard-coded mappings to use a per-module declared
"TCL_NAME" instead.  Add a mapping for vtkIOXdmf2 -> vtkIOXdmfII.

Change-Id: I2a6d708eadd746191a77b5efdd1a4385dad73810
parent 6867502d
......@@ -24,11 +24,12 @@ macro(vtk_module _name)
set(${vtk-module-test}_DEPENDS "${vtk-module}")
set(${vtk-module}_IMPLEMENTS "")
set(${vtk-module}_DESCRIPTION "description")
set(${vtk-module}_TCL_NAME "${vtk-module}")
set(${vtk-module}_EXCLUDE_FROM_ALL 0)
set(${vtk-module}_EXCLUDE_FROM_WRAPPING 0)
set(${vtk-module}_EXCLUDE_FROM_WRAP_HIERARCHY 0)
foreach(arg ${ARGN})
if("${arg}" MATCHES "^((|COMPILE_|TEST_|)DEPENDS|DESCRIPTION|IMPLEMENTS|DEFAULT|GROUPS)$")
if("${arg}" MATCHES "^((|COMPILE_|TEST_|)DEPENDS|DESCRIPTION|TCL_NAME|IMPLEMENTS|DEFAULT|GROUPS)$")
set(_doing "${arg}")
elseif("${arg}" MATCHES "^EXCLUDE_FROM_ALL$")
set(_doing "")
......@@ -52,6 +53,9 @@ macro(vtk_module _name)
elseif("${_doing}" MATCHES "^DESCRIPTION$")
set(_doing "")
set(${vtk-module}_DESCRIPTION "${arg}")
elseif("${_doing}" MATCHES "^TCL_NAME")
set(_doing "")
set(${vtk-module}_TCL_NAME "${arg}")
elseif("${_doing}" MATCHES "^IMPLEMENTS$")
list(APPEND ${vtk-module}_DEPENDS "${arg}")
list(APPEND ${vtk-module}_IMPLEMENTS "${arg}")
......@@ -75,6 +79,10 @@ macro(vtk_module _name)
list(SORT ${vtk-module}_DEPENDS) # Deterministic order.
list(SORT ${vtk-module-test}_DEPENDS) # Deterministic order.
list(SORT ${vtk-module}_IMPLEMENTS) # Deterministic order.
if(NOT ${vtk-module}_EXCLUDE_FROM_WRAPPING AND
"${${vtk-module}_TCL_NAME}" MATCHES "[0-9]")
message(AUTHOR_WARNING "Specify a TCL_NAME with no digits.")
endif()
endmacro()
macro(vtk_module_check_name _name)
......
......@@ -46,25 +46,13 @@ function(vtk_add_tcl_wrapping module_name module_srcs module_hdrs)
foreach(dep ${${vtk-module}_DEPENDS})
if(NOT "${vtk-module}" STREQUAL "${dep}")
if(NOT ${dep}_EXCLUDE_FROM_WRAPPING)
if("${dep}" STREQUAL "vtkRenderingContext2D")
set(dep "vtkRenderingContextIID")
elseif("${dep}" STREQUAL "vtkRenderingGL2PS")
set(dep "vtkRenderingGLtoPS")
endif()
list(APPEND extra_links ${dep}TCL)
list(APPEND extra_links ${${dep}_TCL_NAME}TCL)
endif()
endif()
endforeach()
# Tcl will not accept module names with numbers in.
set(tcl_module ${module_name})
if("${tcl_module}" STREQUAL "vtkRenderingContext2D")
set(tcl_module "vtkRenderingContextIID")
elseif("${tcl_module}" STREQUAL "vtkViewsContext2D")
set(tcl_module "vtkViewsContextIID")
elseif("${tcl_module}" STREQUAL "vtkRenderingGL2PS")
set(tcl_module "vtkRenderingGLtoPS")
endif()
set(tcl_module ${${module_name}_TCL_NAME})
vtk_wrap_tcl3(${tcl_module}TCL Tcl_SRCS "${module_srcs}" "")
vtk_add_library(${tcl_module}TCL ${Tcl_SRCS} ${extra_srcs})
if(CMAKE_HAS_TARGET_INCLUDES)
......
vtk_module(vtkIOXdmf2
TCL_NAME vtkIOXdmfII
GROUPS
DEPENDS
vtkCommonCore
......
vtk_module(vtkRenderingContext2D
TCL_NAME vtkRenderingContextIID
GROUPS
Rendering
DEPENDS
......
vtk_module(vtkRenderingGL2PS
TCL_NAME vtkRenderingGLtoPS
DEPENDS
vtkRenderingContext2D
vtkRenderingMathText
......
vtk_module(vtkViewsContext2D
TCL_NAME vtkViewsContextIID
GROUPS
Views
Rendering
......
......@@ -60,14 +60,7 @@ get_property(VTK_TCL_WRAPPED GLOBAL PROPERTY VTK_TCL_WRAPPED)
# Format the list in a way Tcl expects it
unset(VTK_TCL_WRAPPED_MODULES)
foreach(module ${VTK_TCL_WRAPPED})
string(REGEX REPLACE "^vtk" "" tcl_module ${module})
if("${tcl_module}" STREQUAL "RenderingContext2D")
set(tcl_module "RenderingContextIID")
elseif("${tcl_module}" STREQUAL "ViewsContext2D")
set(tcl_module "ViewsContextIID")
elseif("${tcl_module}" STREQUAL "RenderingGL2PS")
set(tcl_module "RenderingGLtoPS")
endif()
string(REGEX REPLACE "^vtk" "" tcl_module ${${module}_TCL_NAME})
set(VTK_TCL_WRAPPED_MODULES "${VTK_TCL_WRAPPED_MODULES} ${tcl_module}")
endforeach()
......@@ -130,14 +123,7 @@ if(BUILD_SHARED_LIBS)
target_link_libraries(vtk vtkCommonCoreTCL)
else()
foreach(module ${VTK_TCL_WRAPPED})
if("${module}" STREQUAL "vtkRenderingContext2D")
set(module "vtkRenderingContextIID")
elseif("${module}" STREQUAL "vtkViewsContext2D")
set(module "vtkViewsContextIID")
elseif("${module}" STREQUAL "vtkRenderingGL2PS")
set(module "vtkRenderingGLtoPS")
endif()
target_link_libraries(vtk ${module}TCL)
target_link_libraries(vtk ${${module}_TCL_NAME}TCL)
endforeach()
endif()
......@@ -197,14 +183,7 @@ if(vtkParallelMPI_ENABLED)
target_link_libraries(pvtk vtkCommonCoreTCL)
else()
foreach(module ${VTK_TCL_WRAPPED})
if("${module}" STREQUAL "vtkRenderingContext2D")
set(module "vtkRenderingContextIID")
elseif("${module}" STREQUAL "vtkViewsContext2D")
set(module "vtkViewsContextIID")
elseif("${module}" STREQUAL "vtkRenderingGL2PS")
set(module "vtkRenderingGLtoPS")
endif()
target_link_libraries(pvtk ${module}TCL)
target_link_libraries(pvtk ${${module}_TCL_NAME}TCL)
endforeach()
endif()
......@@ -288,18 +267,9 @@ if(NOT VTK_INSTALL_NO_RUNTIME)
endif()
# We must write out a file for each wrapped module to load the SO.
foreach(module ${VTK_TCL_WRAPPED})
foreach(mod ${VTK_TCL_WRAPPED})
set(module "${${mod}_TCL_NAME}")
string(TOLOWER ${module} module_lc)
if(module_lc STREQUAL "vtkrenderingcontext2d")
set(module_lc "vtkrenderingcontextiid")
set(module "vtkRenderingContextIID")
elseif(module_lc STREQUAL "vtkviewscontext2d")
set(module_lc "vtkviewscontextiid")
set(module "vtkViewsContextIID")
elseif(module_lc STREQUAL "vtkrenderinggl2ps")
set(module_lc "vtkrenderinggltops")
set(module "vtkRenderingGLtoPS")
endif()
configure_file(vtkmodule.tcl.in
"${VTK_TCL_HOME}/${module_lc}/${module_lc}.tcl" @ONLY IMMEDIATE)
if(NOT VTK_INSTALL_NO_RUNTIME)
......@@ -332,14 +302,7 @@ ENDIF()
if(NOT BUILD_SHARED_LIBS)
file(REMOVE ${VTK_BINARY_DIR}/Wrapping/Tcl/vtktcl_static_prototypes.h ${VTK_BINARY_DIR}/Wrapping/Tcl/vtktcl_static_packages.h)
foreach(module ${VTK_TCL_WRAPPED})
if("${module}" STREQUAL "vtkRenderingContext2D")
set(module "vtkRenderingContextIID")
elseif("${module}" STREQUAL "vtkViewsContext2D")
set(module "vtkViewsContextIID")
elseif("${module}" STREQUAL "vtkRenderingGL2PS")
set(module "vtkRenderingGLtoPS")
endif()
string(TOLOWER ${module} module_lc)
string(TOLOWER ${${module}_TCL_NAME} module_lc)
string(REGEX REPLACE "^vtk" "Vtk" module_lc ${module_lc})
file(APPEND ${VTK_BINARY_DIR}/Wrapping/Tcl/vtktcl_static_prototypes.h "extern \"C\" int ${module_lc}tcl_Init(Tcl_Interp *interp);\n")
file(APPEND ${VTK_BINARY_DIR}/Wrapping/Tcl/vtktcl_static_packages.h "Tcl_StaticPackage(0, \"${module}Tcl\", ${module_lc}tcl_Init, NULL);\n")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment