# Wrapper hierarchy file

**URL:** <https://discourse.vtk.org/t/wrapper-hierarchy-file/1552>\
**Category:** Development\
**Created:** [August 10, 2019, 10:05pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552 "2019-08-10T22:05:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [August 10, 2019, 10:05pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/1 "2019-08-10T22:05:48Z")

</div>

Hello @ben.boeckel,

I have heard that you are familiar with the wrapper “engine” of VTK and you can help me with a problem of my library. I don’t know how to fix this error:

```auto
[66%] Python Wrapping - generating vtkboolPythonInit.cxx
make[2]: *** No rule to make target '../vtkboolHierarchy', needed by 'vtkPolyDataBooleanFilterPython.cxx'. Stop.
make[1]: *** [CMakeFiles/Makefile2:154: CMakeFiles/vtkboolPythonD.dir/all] Error 2
make: *** [Makefile:95: all] Error

```

It only happens with VTK8. There is an older documentation ([https://vtk.org/Wiki/VTK/WrapHierarchy](https://vtk.org/Wiki/VTK/WrapHierarchy)) about it, but that doesn’t help me. I don’t know what is missing.

Here is the link to my project: [https://github.com/zippy84/vtkbool](https://github.com/zippy84/vtkbool)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [August 12, 2019, 2:15pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/2 "2019-08-12T14:15:31Z")

</div>

I’m not as familiar with the VTK 8.x wrapping CMake APIs (@dgobbi may have better information here). I think you need to call `vtk_wrap_hierarchy(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR} vtkPolyDataBooleanFilter.cxx)`. Though scoping and expected directories may not be correct there.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [August 12, 2019, 2:39pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/3 "2019-08-12T14:39:19Z")

</div>

Hi Ronald,

For VTK 8, something like this is needed at the top of the VTK\_WRAP\_PYTHON section:

```
if(${VTK_MAJOR_VERSION} GREATER 7)
  set(MODULE_HIERARCHY_NAME ${PROJECT_NAME}Hierarchy)
  include(vtkWrapHierarchy)
  vtk_wrap_hierarchy(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR} vtkPolyDataBooleanFilter.h)
  set(KIT_HIERARCHY_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.txt)
  set(LIB_HIERARCHY_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.stamp.txt)
endif()
```

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [August 12, 2019, 3:23pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/4 "2019-08-12T15:23:05Z")

</div>

> [@ben.boeckel](#):
>
> I’m not as familiar with the VTK 8.x wrapping CMake APIs

@mwestphal told me that.

@dgobbi Thanks, I will try it when I’m home.

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [August 12, 2019, 6:07pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/5 "2019-08-12T18:07:44Z")

</div>

@dgobbi It works except for one thing:

```
21/21 Testing: Test_Py
21/21 Test: Test_Py
Command: "/usr/bin/python3.6" "/home/zippy/vtkbool/testing/test_py_module.py" "/home/zippy/VTK8/lib64/python3.6/site-packages" "/home/zippy/vtkbool/build" "Release"
Directory: /home/zippy/vtkbool/build
"Test_Py" start time: Aug 12 19:49 CEST
Output:
----------------------------------------------------------
Traceback (most recent call last):
  File "/home/zippy/vtkbool/testing/test_py_module.py", line 28, in <module>
    vtkboolPython.vtkPolyDataBooleanFilter()
TypeError: this class cannot be instantiated

```

The generated vtkboolHierarchy.txt is:

```
HolesType = std::vector<IdsType> ; vtkPolyDataBooleanFilter.h ; vtkbool
InvolvedType = std::set<int> ; vtkPolyDataBooleanFilter.h ; vtkbool
MergePt ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
PStrips ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
PolyStripsType = std::map<int, PStrips> ; vtkPolyDataBooleanFilter.h ; vtkbool
RefsType = std::vector<std::reference_wrapper<StripPtR> > ; vtkPolyDataBooleanFilter.h ; vtkbool
Rel : enum ; vtkPolyDataBooleanFilter.h ; vtkbool
RelationsType = std::map<int, Rel> ; vtkPolyDataBooleanFilter.h ; vtkbool
StripPt ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
StripPtL ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
StripPtL2 ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
StripPtL3 ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
StripPtR ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
StripPtsType = std::map<int, StripPt> ; vtkPolyDataBooleanFilter.h ; vtkbool
StripType = std::deque<StripPtR> ; vtkPolyDataBooleanFilter.h ; vtkbool
StripsType = std::vector<StripType> ; vtkPolyDataBooleanFilter.h ; vtkbool
_Wrapper ; vtkPolyDataBooleanFilter.h ; vtkbool ; WRAP_EXCLUDE_PYTHON
vtkPolyDataBooleanFilter : vtkPolyDataAlgorithm ; vtkPolyDataBooleanFilter.h ; vtkbool
vtkPolyDataBooleanFilter::Superclass = vtkPolyDataAlgorithm ; vtkPolyDataBooleanFilter.h ; vtkbool

```

What could be wrong?

Here is the changed CMakeLists.txt: [https://github.com/zippy84/vtkbool/blob/hierarchy/CMakeLists.txt](https://github.com/zippy84/vtkbool/blob/hierarchy/CMakeLists.txt)

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [August 12, 2019, 7:25pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/6 "2019-08-12T19:25:39Z")

</div>

Oops, I missed setting the “WRAP\_DEPENDS” variable that vtkWrapHierarchy needs. Try this:

```
if(${VTK_MAJOR_VERSION} GREATER 7)
  set(MODULE_HIERARCHY_NAME ${PROJECT_NAME}Hierarchy)
  set(${PROJECT_NAME}_WRAP_DEPENDS vtkCommonExecutionModel)
  include(vtkWrapHierarchy)
  vtk_wrap_hierarchy(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR} vtkPolyDataBooleanFilter.h)
  set(KIT_HIERARCHY_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.txt)
  set(LIB_HIERARCHY_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.stamp.txt)
endif()
```

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [August 12, 2019, 7:37pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/7 "2019-08-12T19:37:02Z")

</div>

@dgobbi It works 🙂

Will there ever be a _good_ documentation about it?

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [August 12, 2019, 8:30pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/8 "2019-08-12T20:30:40Z")

</div>

Maybe. If there was good documentation, where would you go to find it? I’m not sure where people look for VTK info these days, other than here and the doxygen pages.

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [October 21, 2019, 2:12pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/9 "2019-10-21T14:12:36Z")

</div>

@dgobbi

There is a problem with your code. I tried it under Fedora 30 with VTK 8.1.1 and I still get

```auto
make[2]: *** No rule to make target 'vtkbool/vtkboolHierarchy.txt', needed by 'vtkbool/vtkPolyDataBooleanFilterPython.cxx'. Stop.
make[1]: *** [CMakeFiles/Makefile2:521: vtkbool/CMakeFiles/vtkboolPythonD.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

```

The vtkboolHierarchy.txt is missing.

Do you have any idea?

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [October 21, 2019, 3:46pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/10 "2019-10-21T15:46:07Z")

</div>

Is it working with VTK 8.2, but just not with VTK 8.1?

There is a lot of code churn in VTK’s cmake files from one version of VTK to the next, and wrapping techniques that work with one version often don’t work with others.

For my vtk-dicom project, I wrote a customized vtkWrapHierarchy.cmake in order to get the wrapping to work with multiple versions of VTK. In particular, I suspect the patch needed to fix the “…Hierarchy.txt is missing” error is this one:

[https://github.com/dgobbi/vtk-dicom/commit/5606a03](https://github.com/dgobbi/vtk-dicom/commit/5606a03)

Similar changes were made to VTK’s own vtkWrapHierarchy.cmake for VTK 8.2, but they are absent in VTK 8.1.

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [October 22, 2019, 9:20am UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/11 "2019-10-22T09:20:16Z")

</div>

With your code I was able to write this:

```auto
if(${VTK_VERSION} VERSION_EQUAL "8.1")
    configure_file(
        ${VTK_CMAKE_DIR}/vtkWrapperInit.data.in
        ${MODULE_HIERARCHY_NAME}.data
        @ONLY
    )

    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.txt
            ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.stamp.txt
        COMMAND ${VTK_WRAP_HIERARCHY_EXE} -o ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.txt
                ${MODULE_HIERARCHY_NAME}.data #[[something is missing here]]
        COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.stamp.txt
        DEPENDS ${VTK_WRAP_HIERARCHY_EXE}
            ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.data
        VERBATIM)
endif()

```

This generates the vtkboolHierarchy.txt, but the file is not big enough. What’s missing?

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [October 22, 2019, 12:43pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/12 "2019-10-22T12:43:02Z")

</div>

You are missing the “`${OTHER\_HIERARCHY\_FILES}” argument, which is a list of the hierarchy files for all the libraries that your library links to:

[https://github.com/dgobbi/vtk-dicom/blob/5606a03/CMake/vtkWrapHierarchy.cmake#L126](https://github.com/dgobbi/vtk-dicom/blob/5606a03/CMake/vtkWrapHierarchy.cmake#L126)

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [October 22, 2019, 12:50pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/13 "2019-10-22T12:50:22Z")

</div>

But what are they, in my case? I’m linking with ${VTK\_LIBRARIES}. find\_package is this `find_package(VTK REQUIRED COMPONENTS vtkFiltersSources vtkIOLegacy vtkFiltersExtraction vtkFiltersGeometry vtkFiltersModeling vtkRenderingFreeType OPTIONAL_COMPONENTS vtkWrappingPythonCore NO_MODULE)`.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [October 22, 2019, 12:57pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/14 "2019-10-22T12:57:42Z")

</div>

Are you saying that there is no `vtkbool_LINK_DEPENDS` for your library?  
What do you get if you try to print its value?

```
message(STATUS "vtkbool_LINK_DEPENDS ${vtkbool_LINK_DEPENDS}")
```

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [October 22, 2019, 1:02pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/15 "2019-10-22T13:02:48Z")

</div>

> [@dgobbi](#):
>
> message(STATUS “vtkbool\_LINK\_DEPENDS ${vtkbool\_LINK\_DEPENDS}”)

Yes, it is empty. I’m currently not using vtk.module and module.cmake. (I’m still waiting for @lorensen PR.)

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [October 22, 2019, 1:08pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/16 "2019-10-22T13:08:18Z")

</div>

Ah, I looked through my own code, and it seems that I had to set it myself:

[https://github.com/dgobbi/vtk-dicom/blob/5606a03/Source/CMakeLists.txt#L142](https://github.com/dgobbi/vtk-dicom/blob/5606a03/Source/CMakeLists.txt#L142)

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [October 22, 2019, 1:23pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/17 "2019-10-22T13:23:30Z")

</div>

Could you please look at my code? I’m unfortunately don’t know what to do ☹

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [October 22, 2019, 1:45pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/18 "2019-10-22T13:45:20Z")

</div>

Just try setting `vtkbool_LINK_DEPENDS` and then build the `OTHER_HIERARCHY_FILES` with the code that I linked. For example,

```
set(vtkbool_LINK_DEPENDS vtkFiltersSources vtkIOLegacy vtkFiltersExtraction vtkFiltersGeometry vtkFiltersModeling vtkRenderingFreeType)
```

---

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [October 23, 2019, 9:12pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/19 "2019-10-23T21:12:15Z")

</div>

@dgobbi Thanks for your help! It works 🙂

There is one question left. You are using the args-files in your custom\_command. Can you say why? The content is just a list of -I"…" entries.

My code btw:

```auto
if(${VTK_MAJOR_VERSION} GREATER 7)
    set(MODULE_HIERARCHY_NAME ${PROJECT_NAME}Hierarchy)
    set(${PROJECT_NAME}_WRAP_DEPENDS vtkCommonExecutionModel)

    set(${PROJECT_NAME}_LINK_DEPENDS vtkCommonExecutionModel)

    include(vtkWrapHierarchy)
    vtk_wrap_hierarchy(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR} vtkPolyDataBooleanFilter.h)
    set(KIT_HIERARCHY_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.txt)
    set(LIB_HIERARCHY_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.stamp.txt)

    if(${VTK_VERSION} VERSION_EQUAL "8.1")
        configure_file(
            ${VTK_CMAKE_DIR}/vtkWrapperInit.data.in
            ${MODULE_HIERARCHY_NAME}.data
            @ONLY
        )

        set(OTHER_HIERARCHY_FILES)

        foreach(dep ${${PROJECT_NAME}_LINK_DEPENDS})
            list(APPEND OTHER_HIERARCHY_FILES "${${dep}_WRAP_HIERARCHY_FILE}")
        endforeach()

        add_custom_command(OUTPUT ${KIT_HIERARCHY_FILE}
                ${LIB_HIERARCHY_STAMP}
            COMMAND ${VTK_WRAP_HIERARCHY_EXE} -o ${KIT_HIERARCHY_FILE}
                    ${MODULE_HIERARCHY_NAME}.data ${OTHER_HIERARCHY_FILES}
            COMMAND ${CMAKE_COMMAND} -E touch ${LIB_HIERARCHY_STAMP}
            DEPENDS ${VTK_WRAP_HIERARCHY_EXE}
                ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_HIERARCHY_NAME}.data
                ${OTHER_HIERARCHY_FILES}
            VERBATIM)
    endif()

endif()

```

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [October 23, 2019, 10:16pm UTC](https://discourse.vtk.org/t/wrapper-hierarchy-file/1552/20 "2019-10-23T22:16:15Z")

</div>

Glad to hear that it is working. I wasn’t sure if the fedora VTK package would include all of the necessary files.

The “`-I...`” entries in the args file are used when vtkWrapHierarchy processes “`#include`” directives. There are some situations where this can be important.

Consider when vtkWrapHierarchy processes a file called vtkMyClass.h that contains this code:

```auto
#include "vtkConfigure.h" /* might define VTK_LEGACY_REMOVE */

#ifndef VTK_LEGACY_REMOVE
   /* define a legacy method */
#endif

```

In this case, vtkWrapHierarchy needs the “`-I`” args so that it can find vtkConfigure.h, because otherwise it will not know if VTK\_LEGACY\_REMOVE is defined (it will assume that it is not defined).

Note that VTK\_LEGACY\_REMOVE is just one example. The “`-I`” args are needed whenever you are wrapping a header file that needs things that were `#define`'d in other headers.
