# Issue with client-server wrapper and cmake

**URL:** <https://discourse.kitware.com/t/issue-with-client-server-wrapper-and-cmake/368>\
**Category:** Using SMTK\
**Created:** [December 23, 2019, 5:51pm UTC](https://discourse.kitware.com/t/issue-with-client-server-wrapper-and-cmake/368 "2019-12-23T17:51:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)\
**Post date:** [December 23, 2019, 5:51pm UTC](https://discourse.kitware.com/t/issue-with-client-server-wrapper-and-cmake/368/1 "2019-12-23T17:51:54Z")

</div>

@ben.boeckel @tj.corona I’m having an issue adding a Registrar class to `smtk/extension/vtk/source`… when CMake runs, it complains:

```nohighlight
-- Configuring done
CMake Error at /stage/build/cmb/superbuild/superbuild/paraview/build/lib/cmake/paraview-5.7/vtkModuleWrapClientServer.cmake:81 (add_custom_command):
  Attempt to add a custom rule to output

    /stage/build/smtk/4/smtk/extension/paraview/server/plugin/CMakeFiles/RegistrarClientServer.cxx.rule

  which already has a custom rule.
Call Stack (most recent call first):
  /stage/build/cmb/superbuild/superbuild/paraview/build/lib/cmake/paraview-5.7/vtkModuleWrapClientServer.cmake:140 (_vtk_module_wrap_client_server_sources)
  /stage/build/cmb/superbuild/superbuild/paraview/build/lib/cmake/paraview-5.7/vtkModuleWrapClientServer.cmake:305 (_vtk_module_wrap_client_server_library)
  /stage/build/cmb/superbuild/superbuild/paraview/build/lib/cmake/paraview-5.7/ParaViewPlugin.cmake:979 (vtk_module_wrap_client_server)
  smtk/extension/paraview/server/plugin/CMakeLists.txt:4 (paraview_add_plugin)

-- Generating done

```

I ended up building a custom CMake to print out more information about what’s happening… for some reason the vtkModuleWrapClientServer CMake code wants to output a wrapper for the class in `smtk/extension/vtk/source` into the `smtk/extension/paraview/server` directory (which already has a wrapper for a class of the same name, causing the conflict). The custom command lines being generated are

```auto
    ParaView::WrapClientServer
    @/stage/build/smtk/4/smtk/extension/paraview/server/plugin/CMakeFiles/smtkPVServerExt-client-server.$<CONFIGURATION>.args
    -o
    /stage/build/smtk/4/smtk/extension/paraview/server/plugin/CMakeFiles/RegistrarClientServer.cxx
    /stage/source/smtk/4/smtk/extension/paraview/server/Registrar.h
    --types
    /stage/build/smtk/4/lib/vtk/hierarchy/SMTKParaViewVTKModules/smtkPVServerExt-hierarchy.txt

```

vs

```auto
    ParaView::WrapClientServer
    @/stage/build/smtk/4/smtk/extension/paraview/server/plugin/CMakeFiles/vtkSMTKSourceExt-client-server.$<CONFIGURATION>.args
    -o
    /stage/build/smtk/4/smtk/extension/paraview/server/plugin/CMakeFiles/RegistrarClientServer.cxx
    /stage/source/smtk/4/smtk/extension/vtk/source/Registrar.h
    --types
    /stage/build/smtk/4/lib/vtk/hierarchy/SMTKVTKModules/vtkSMTKSourceExt-hierarchy.txt

```

You can see the second one is incorrect (the `-o ...` path is wrong). I don’t see why ParaView’s wrapper generator rule (in `lib/cmake/paraview-5.7/vtkModuleWrapClientServer.cmake`) would generate bad output paths. Do you?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.kitware.com/u/ben.boeckel)\
**Post date:** [December 28, 2019, 1:15pm UTC](https://discourse.kitware.com/t/issue-with-client-server-wrapper-and-cmake/368/2 "2019-12-28T13:15:34Z")

</div>

No, that path is right. ClientServer sources are all stuffed into `CMakeFiles` where the `vtk_module_wrap_client_server` is called. I guess we could use a subdirectory per CS library instead.

This assumption had been OK because VTK already has a “no headers can conflict” because of the “dump everything in one directory” pattern done there. Python and Java wrappers should do the same thing.

The solution would be to change `_vtk_client_server_source_output` to have a `${_vtk_client_server_library_name}CS` subdirectory in there. Similar for the other wrappers.

---

<div class="post-metadata">

**Author:** ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)\
**Post date:** [December 28, 2019, 3:42pm UTC](https://discourse.kitware.com/t/issue-with-client-server-wrapper-and-cmake/368/3 "2019-12-28T15:42:18Z")

</div>

> [@ben.boeckel](#):
>
> This assumption had been OK because VTK already has a “no headers can conflict” because of the “dump everything in one directory” pattern done there.

That might still have been OK if fully-qualified names (including namespaces) were used.

> [@ben.boeckel](#):
>
> The solution would be to change `_vtk_client_server_source_output` to have a `${_vtk_client_server_library_name}CS` subdirectory in there.

That’s probably easier than extracting namespaces and adding those to paths. I’ve submitted [PV MR 3791](https://gitlab.kitware.com/paraview/paraview/merge_requests/3791) to do this.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.kitware.com/u/ben.boeckel)\
**Post date:** [December 30, 2019, 4:10pm UTC](https://discourse.kitware.com/t/issue-with-client-server-wrapper-and-cmake/368/4 "2019-12-30T16:10:04Z")

</div>

> [@dcthomp](#):
>
> That might still have been OK if fully-qualified names (including namespaces) were used.

The output file needs to be determined at configure time; we can’t read the C++ code to figure out the symbol name at that point reliably.
