1# This file ensures that any module that should be wrapped has the
2# vtkWrapHierarchy command executed on it, and also dispatches to the language
3# specific wrapping for each module.
4
5# First, ensure we include the correct CMake code so that we can wrap.
6if(VTK_WRAP_PYTHON)
7#  include(vtkPythonWrapping)
8endif()
9if(VTK_WRAP_TCL)
10  include(vtkTclWrapping)
11endif()
12if(VTK_WRAP_JAVA)
13  include(vtkJavaWrapping)
14endif()
15
16include(vtkWrapHierarchy)
17
18if(${CMAKE_VERSION} VERSION_GREATER 2.8.7.20120314)
19  set(CMAKE_HAS_TARGET_INCLUDES TRUE)
20endif()
21
22# This is the main function, always called from the vtk_module_library function
23# when a new module library is added.
24function(vtk_add_wrapping module_name module_srcs module_hdrs)
25  if(NOT ${module_name}_EXCLUDE_FROM_WRAPPING)
26    set(_wrap_module FALSE)
27    if(VTK_WRAP_PYTHON OR VTK_WRAP_TCL OR VTK_WRAP_JAVA)
28      set(_wrap_module TRUE)
29    endif()
30
31    if(_wrap_module)
32      # The list of include dirs to pass to wrapper tool command lines
33      set(VTK_WRAP_INCLUDE_DIRS)
34      if(${vtk-module}_DEPENDS_INCLUDE_DIRS)
35        list(APPEND VTK_WRAP_INCLUDE_DIRS ${${vtk-module}_DEPENDS_INCLUDE_DIRS})
36      endif()
37      if(${vtk-module}_INCLUDE_DIRS)
38        list(APPEND VTK_WRAP_INCLUDE_DIRS ${${vtk-module}_INCLUDE_DIRS})
39      endif()
40      if(${vtk-module}_SYSTEM_INCLUDE_DIRS)
41        list(APPEND VTK_WRAP_INCLUDE_DIRS ${${vtk-module}_SYSTEM_INCLUDE_DIRS})
42      endif()
43
44      # The module is wrapped by at least one language - invoke wrap hierarchy.
45      if(NOT ${module_name}_EXCLUDE_FROM_WRAP_HIERARCHY)
46        set(_all_files ${module_srcs} ${modules_hdrs})
47        vtk_wrap_hierarchy(${module_name}Hierarchy ${VTK_MODULES_DIR}
48          "${_all_files}")
49        set (${module_name}_WRAP_HIERARCHY_FILE
50          "${VTK_MODULES_DIR}/${module_name}Hierarchy.txt"
51          PARENT_SCOPE)
52        set (${module_name}_WRAP_HIERARCHY_FILE
53          "${VTK_MODULES_DIR}/${module_name}Hierarchy.txt")
54      endif()
55
56      # Now to wrap the languages that are on.
57      if(VTK_WRAP_PYTHON AND NOT ${module_name}_EXCLUDE_FROM_PYTHON_WRAPPING)
58        # Note that the module should be Python wrapped.
59        set_property(GLOBAL APPEND PROPERTY VTK_PYTHON_WRAPPED ${module_name})
60      endif()
61      if(VTK_WRAP_TCL AND NOT ${module_name}_EXCLUDE_FROM_TCL_WRAPPING)
62        set_property(GLOBAL APPEND PROPERTY VTK_TCL_WRAPPED ${module_name})
63        vtk_add_tcl_wrapping(${module_name} "${module_srcs}" "${module_hdrs}")
64      endif()
65      if(VTK_WRAP_JAVA AND NOT ${module_name}_EXCLUDE_FROM_JAVA_WRAPPING)
66        set_property(GLOBAL APPEND PROPERTY VTK_JAVA_WRAPPED ${module_name})
67        vtk_add_java_wrapping(${module_name} "${module_srcs}" "${module_hdrs}")
68      endif()
69    endif()
70  endif()
71endfunction()
72