Itk: "vtk_module_config" removed from VTK

Created on 17 Jan 2019  路  23Comments  路  Source: InsightSoftwareConsortium/ITK

Description

VtkGlue doesn't compile with latest version of VTK (new module structure). I expect LevelSetsv4Visualization to have the same problem.

Steps to Reproduce

  1. Clone VTK github repository and compile it
  2. Compile ITK with VtkGlue ON

Expected behavior

CMake should configure the project correctly.

Actual behavior

Currently, the following CMake error is printed:

Unknown CMake command "vtk_module_config"

Reproducibility

All the time.

Versions

VTK version > 8.2.0 will have this problem as the required CMake macro used by ITK to configure the remote modules that use VTK has been removed from VTK in commit 8d61ac62bfb3c532d1d3506d5f7fd495e49c4295.

Environment

Ubuntu 18.04 but this should happen on any environment.

Additional Information

This issue arises because the VTK module system has been fully reworked. A person that knows the new module system could probably fix the problem really fast. Information about the new VTK module system should be posted in this issue to help the person that is going to fix this problem.

ThirdParty

Most helpful comment

Thanks. I did not fork ITK in the first place but only made a local clone.

PR submitted to: https://github.com/InsightSoftwareConsortium/ITK/pull/731

BR,

All 23 comments

LevelSetsv4Visualization has been broken for a while, see Corista build here, but it has been manifesting itself as runtime error when visualizing something is attempted.

LevelSetsv4Visualization's CMake code seems to be mostly duplicated from VTKGlue. It would be good if that duplication is gotten rid of, and simple dependency between them is introduced.

@seanm CC'ing myself...

I can confirm this issue is also happening in Windows (visual studio 2017).

edit:

I added the following after set(ITKVtkGlue_LIBRARIES ITKVtkGlue) of VtkGlue's CMakeLists.txt file:

if(NOT COMMAND vtk_module_config)
  macro(vtk_module_config ns)   
     foreach(arg ${ARGN})  
      if(${arg} MATCHES "^[Vv][Tt][Kk]")
        string(REGEX REPLACE "^[Vv][Tt][Kk]" "" _arg ${arg})
      else()
        set(_arg ${arg})
      endif()
      set(${ns}_LIBRARIES ${${ns}_LIBRARIES} VTK::${_arg})
     endforeach()
  endmacro()

  if(NOT VTK_RENDERING_BACKEND)
    set(VTK_RENDERING_BACKEND OpenGL2)
  endif()
endif()

This should not interfere with other vtk versions not using new target building. I added OpenGL2 rendering because vtkRenderingOpenGL is not defined as a valid target in my case. Maybe this is not necessary.

This is a quick and dirty hack to build ITKVtkGlue, I have yet to check that external projects linking against ITKVtkGlue work properly. I use vtk 8.9 and itk 5.0.

VTK's new module system was merged exactly 2 weeks ago now (January 9), any chance ITK can be working with VTK again soon?

So I guess nobody at Kitware uses VTK & ITK together? :(

There are many combinations of versions and modules, so not all are routinely used/tested.

If I'm not mistaken, it's not an obscure combination that's broken, but a vanilla VTK git master + ITK git master. It's been broken since Kitware made the big build system changes in VTK the other week.

@schmidje well done on the update! Could it be contributed to the repository?

@thewtex Well itk does build but I had to add additional mess on the file to be able to use ITKVtkGlue outside of itk, and honestly I am definitively not sure that the fixes will work. In this context, itk gurus of the cmake modules should instead investigate closely the issue....

I also found that the exported targets do NOT include the include paths of the targets... (whereas vtk does it properly in the new update) which somehow reduce the interest as you cannot just use a target_link_library(...someItkModule...) and have the include paths set automatically. But this is another story...!

@schmidje did you also add the compatibility macro to ITKVtkGlue_EXPORT_CODE_INSTALL and ITKVtkGlue_EXPORT_CODE_BUILD?

@thewtex Well it looks like I did:

I put in the ITKVtkGlue_EXPORT_CODE_INSTALL part:

set(ITKVtkGlue_EXPORT_CODE_INSTALL "
set(VTK_DIR \"${VTK_DIR}\")

find_package(VTK NO_MODULE REQUIRED)

# included part starts here
  if(NOT COMMAND vtk_module_config)
    macro(vtk_module_config ns)   
       foreach(arg \${ARGN})  
        if(\${arg} MATCHES \"^[Vv][Tt][Kk]\")
          string(REGEX REPLACE \"^[Vv][Tt][Kk]\" \"\" _arg \${arg})
        else()
          set(_arg \${arg})
        endif()
        set(\${ns}_LIBRARIES \${\${ns}_LIBRARIES} VTK::\${_arg})
       endforeach()
    endmacro()
  endif()
# included part ends here

if(NOT VTK_VERSION)

(...continues)
")

Then in the ITKVtkGlue_EXPORT_CODE_BUILD I did the same:

set(ITKVtkGlue_EXPORT_CODE_BUILD "
if(NOT ITK_BINARY_DIR)
  set(VTK_DIR \"${VTK_DIR}\")

# included part starts here
  if(NOT COMMAND vtk_module_config)
    macro(vtk_module_config ns)   
       foreach(arg \${ARGN})  
        if(\${arg} MATCHES \"^[Vv][Tt][Kk]\")
          string(REGEX REPLACE \"^[Vv][Tt][Kk]\" \"\" _arg \${arg})
        else()
          set(_arg \${arg})
        endif()
        set(\${ns}_LIBRARIES \${\${ns}_LIBRARIES} VTK::\${_arg})
       endforeach()
    endmacro()
  endif()
# included part ends here

  find_package(VTK NO_MODULE REQUIRED)
(...continues)
")

@schmidje nice. Could you please create a pull request with the current WIP, so you get credit for your work?

CC: @mathstuf

@lorensen Bill, maybe since you got all the VTKExamples working with the recent VTK changes, you would know how to get ITK working with VTK again?

@thewtex Well I could but first I would like to make sure it is working properly. I messed up some stuff with the update of itk, so I will try to make a test asap.

BR

@schmidje any progress on turning this into a PR?

@dzenanz No, because until very recently I did not test the fix as my itk was not compiling anymore due to conflicts with a system Eigen lib. Now it seems to be ok and I can use VTK and ITK in a same app using the glue so I guess the fix is okay.

Now I don't have experience in submitting pull request to itk and the doc at https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md looks a little intimidating at first. Is this the correct way to go?

Yes, CONTRIBUTING has the instructions. Setup, create a topic and share a topic are the more important sections to get started.

Hi,

I tried to share my topic but I get this error at the git review-push --force stage:

$ git review-push --force
Pushing to origin
remote: Permission to InsightSoftwareConsortium/ITK.git denied to schmidje.
fatal: unable to access 'https://github.com/InsightSoftwareConsortium/ITK.git/': The requested URL returned error: 403

All previous steps listed in the document went smoothly. Am I missing something?

Thanks

Origin should be your fork ([email protected]:schmidje/ITK.git). Upstream should be https://github.com/InsightSoftwareConsortium/ITK.git.

Thanks. I did not fork ITK in the first place but only made a local clone.

PR submitted to: https://github.com/InsightSoftwareConsortium/ITK/pull/731

BR,

Could this go in ITK 4.x also? Would be helpful when regression testing VTK/ITK combos...

@schmidje thanks for the contribution! :1st_place_medal:

Could this go in ITK 4.x also? Would be helpful when regression testing VTK/ITK combos...

@seanm yes, this has been pushed to the release-4.13 branch.

Was this page helpful?
0 / 5 - 0 ratings