Skip to content

WIP: ENH: Adjust RTK applications and example to modern CMake interface#894

Open
SimonRit wants to merge 1 commit intoRTKConsortium:mainfrom
SimonRit:new_cmake
Open

WIP: ENH: Adjust RTK applications and example to modern CMake interface#894
SimonRit wants to merge 1 commit intoRTKConsortium:mainfrom
SimonRit:new_cmake

Conversation

@SimonRit
Copy link
Collaborator

@SimonRit SimonRit commented Feb 3, 2026

@SimonRit SimonRit changed the title ENH: Adjust RTK applications and example to modern CMake interface WIP: ENH: Adjust RTK applications and example to modern CMake interface Feb 4, 2026
@SimonRit
Copy link
Collaborator Author

SimonRit commented Feb 4, 2026

This currently does not work, it does not register ITK factories for an unknown reason. When executing rtkfdk with an .mha output, I get

ExceptionObject caught with itk::WriteImage(streamerBP->GetOutput(), args_info.output_arg) in file /home/srit/src/rtk/rtk/applications/rtkfdk/rtkfdk.cxx line 207

itk::ImageFileWriterException (0x60b925e7f650)
Location: "unknown" 
File: /home/srit/src/itk/itk/Modules/IO/ImageBase/include/itkImageFileWriter.hxx
Line: 117
Description:  Could not create IO object for writing file fdk.mha
  Tried to create one of the following:
    HndImageIO
    HncImageIO
    XimImageIO
    HisImageIO
    ImagXImageIO
    DCMImagXImageIO
    EdfImageIO
    XRadImageIO
    OraImageIO
    HndImageIO
    HncImageIO
    XimImageIO
    HisImageIO
    ImagXImageIO
    DCMImagXImageIO
    EdfImageIO
    XRadImageIO
    OraImageIO
    GDCMImageIO
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.

If I rollback to using include(${ITK_USE_FILE}) in applications/CMakeLists.txt, it does work so there must be something in UseITK.cmake missing in my code. Any pointer is welcome @blowekamp.

@SimonRit
Copy link
Collaborator Author

SimonRit commented Feb 4, 2026

In the latest force push, I added this code copy pasted from UseITK.cmake. Then, RTK's applications work. However, the examples (external applications using RTK) still fail due to missing factories so something's not right and I don't know what.

Copy link
Contributor

@blowekamp blowekamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for trying out the latest changed in ITK right away.

You may want to create a linking function or some variables to avoid the duplicated conditionings.

I was uncertain what to run to reproduce your error messages.

if("${ITK_VERSION_MAJOR}" VERSION_LESS "6")
target_link_libraries(ConjugateGradient ${ITK_LIBRARIES})
else()
target_link_libraries(ConjugateGradient ITK::RTKModule)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were previously linking to all loaded ITK modules, and presumably using them with "UseITK".

Using ITK_INTERFACE_LIBRARIES will apply properties and line to all the ITK::{module-name}Module loaded in the find_package. This may include additional modules no specified as dependents of just the RTK Module.

PROPERTY
COMPILE_DEFINITIONS
ITK_${_factory_uc}_FACTORY_REGISTER_MANAGER
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration guide contains some information on "Factory Registration with Meta Modules": https://docs.itk.org/en/latest/migration_guides/itk_6_migration_guide.html#application-configuration

The docs are missing that an application should also link to the meta-module "ITK::ITKImageIO". These meta-module have the properties of the include and compile definitions in them so they don't need to be set in at a directory/global level.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I have just force-pushed a new version which works. I am not entirely convinced though. Can I make the target RTKModule dependent on ITK::ITKImageIO and ITK::ITKFFTImageFilterInit to avoid having to specify it in each application and example?

By the way, the doc mentions ITKIOFFT which does not exist, I have used ITKFFTImageFilterInit instead.

Thanks again for you support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants