Skip to content

Refactor wrapping to use target properties and address bug building remote modules against an ITK build directory#5842

Merged
blowekamp merged 3 commits intoInsightSoftwareConsortium:mainfrom
blowekamp:fix_wrap_external
Mar 5, 2026
Merged

Refactor wrapping to use target properties and address bug building remote modules against an ITK build directory#5842
blowekamp merged 3 commits intoInsightSoftwareConsortium:mainfrom
blowekamp:fix_wrap_external

Conversation

@blowekamp
Copy link
Copy Markdown
Member

@blowekamp blowekamp commented Feb 26, 2026

Use generator expression to convert target property into properly formatted string for include file. Change to file with GENERATE option to support generator expressions.

There were redundant calls to configure the inc file for each wrapping file. An additional prefix is added to the inc file to create multiple.

This addresses a bug where remote modules could not be wrapped against a build ITK due to missing include paths and definitions.

COMPATIBILITY NOTE: Removes support for directory level properties for includes and defines.

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

Refer to the ITK Software Guide for
further development details if necessary.

@blowekamp
Copy link
Copy Markdown
Member Author

Sorry for short message, issue mostly redundant include with ITK_INCLUDE_DIRS, and target's transitive properties. Needed to keep ITK_INCLUDE_DIRS because of itkMeshRegion.h in Core/Common.

The extra inc files are redundant.

@blowekamp blowekamp requested a review from thewtex February 26, 2026 22:06
@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Python wrapping Python bindings for a class area:Core Issues affecting the Core module area:IO Issues affecting the IO module labels Feb 27, 2026
@@ -1,3 +1,4 @@
set(ITK_MODULE_ITKCommon_WRAPPING_DEPENDS ITK::ITKMeshModule)
Copy link
Copy Markdown
Member Author

@blowekamp blowekamp Feb 27, 2026

Choose a reason for hiding this comment

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

@thewtex There needs to be a way to express that the wrapping for common depends on the Mesh module, or the mesh code needs to be moved to a better place. This follows the convention of (internal?) variable used in ModuleMacro... I wasn't sure if other models had un-described dependencies for wrapping, but it appears not. I am still pondering better ways to specify this for wrapping; I am open to suggestions?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I don't recall the history or the reason for this. Maybe we can ask an agent to try to simplify the dependencies?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have asked my local agent many questions regarding the wrapping code it figure things out. I ended up just hard coding the dep in the TypedefMacros.cmake file. Perhaps this can be revisited after this is merged and remotes are working again for wrapping.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Apparently, it has been there since pre-modularization before 2011, and it was trivial to relocate.

Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Looks good on a glance.

@github-actions github-actions Bot removed the area:Python wrapping Python bindings for a class label Feb 27, 2026
set(
CONFIG_CASTXML_INC_CONTENTS
"${CONFIG_CASTXML_INC_CONTENTS}$<LIST:JOIN,$<LIST:TRANSFORM,$<TARGET_PROPERTY:${_depend},INTERFACE_COMPILE_DEFINITIONS>,REPLACE,^(.+)$,\"-D\\1\">,\n>\n"
)
Copy link
Copy Markdown
Member Author

@blowekamp blowekamp Feb 27, 2026

Choose a reason for hiding this comment

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

@zivy @bradking @thewtex This is some pretty cool code going on with CMake here.

@thewtex
Copy link
Copy Markdown
Member

thewtex commented Feb 27, 2026

Cool! 😎

I recall that we had code to remove redundant include directories -- hopefully this helps with that, too.

@github-actions github-actions Bot added area:Python wrapping Python bindings for a class area:Bridge Issues affecting the Bridge module labels Feb 27, 2026
blowekamp added a commit to blowekamp/ITK that referenced this pull request Mar 2, 2026
Moves MeshRegion wrapping from ITKCommon to ITKMesh module and removes the workaround dependency linkage in TypedefMacros.cmake.

Related to PR InsightSoftwareConsortium#5842
blowekamp added a commit to blowekamp/ITK that referenced this pull request Mar 2, 2026
Changes VTK Bridge module dependency from PRIVATE_DEPENDS to DEPENDS for ITKCommon, making it a public dependency as required.

Related to PR InsightSoftwareConsortium#5842
@blowekamp blowekamp force-pushed the fix_wrap_external branch from 846da46 to 9176640 Compare March 2, 2026 21:14
@github-actions github-actions Bot removed type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Bridge Issues affecting the Bridge module area:IO Issues affecting the IO module labels Mar 2, 2026
@blowekamp blowekamp force-pushed the fix_wrap_external branch from 9176640 to 786e51d Compare March 3, 2026 15:53
@github-actions github-actions Bot added the type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots label Mar 3, 2026
Comment thread Wrapping/TypedefMacros.cmake Outdated
Comment thread Wrapping/TypedefMacros.cmake Outdated
@blowekamp blowekamp force-pushed the fix_wrap_external branch from 786e51d to 6d469c8 Compare March 3, 2026 16:54
@blowekamp
Copy link
Copy Markdown
Member Author

/azp.run ITK.macOS.Python

@blowekamp blowekamp force-pushed the fix_wrap_external branch from 6d469c8 to 12d1e58 Compare March 3, 2026 21:35
@github-actions github-actions Bot added the area:Bridge Issues affecting the Bridge module label Mar 3, 2026
@blowekamp blowekamp marked this pull request as ready for review March 3, 2026 21:36
@blowekamp
Copy link
Copy Markdown
Member Author

I don't think any of the current test failures and build issue are related to this PR.

Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

I tested this locally on Windows + VS2026. MCI built successfully against the build dir.

@blowekamp blowekamp force-pushed the fix_wrap_external branch from 12d1e58 to 9ecba99 Compare March 4, 2026 15:28
@blowekamp blowekamp changed the title Address bug building remote modules against an ITK build directory Refactor wrapping to use target properties and address bug building remote modules against an ITK build directory Mar 4, 2026
@blowekamp blowekamp requested a review from hjmjohnson March 4, 2026 19:32
@blowekamp
Copy link
Copy Markdown
Member Author

@thewtex All the builds came back green, shall we merged this change with the wrapping infrastructure?

@hjmjohnson
Copy link
Copy Markdown
Member

@dzenanz CDash has been hanging. Do you know if there is a problem with the server?

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Mar 5, 2026

I am not aware of any problems. Maybe this CDash GHA check got broken somehow?

Copy link
Copy Markdown
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

@blowekamp awesome!!

Yes, let's merge. Could you please change the base to release?

I need to re-build the Python packages with the Windows patch, and I will include this one, too. Are there others that we need to include?

@blowekamp
Copy link
Copy Markdown
Member Author

blowekamp commented Mar 5, 2026

@blowekamp awesome!!

Yes, let's merge. Could you please change the base to release?

I need to re-build the Python packages with the Windows patch, and I will include this one, too. Are there others that we need to include?

There are 3 other PR's that are link to this one that did minor fixes needed #5850 #5851 #5852. So this make the rebase onto release a little more difficult.

ADDITION: I think the best course of action would the to rebase this onto release. Then merge into release even though the branch is missing those components listed. This will allow testing in main. Then you can cherry pick the listed PRs, and merge this brach into release? Or just do another tag, but there still seems to be a bit of churn with other issues. Please let me know how to proceed.

Use generator expression to convert target property into properly
formatted string for include file. Change to file with GENERATE option
to support generator expressions.

There were redundant calls to configure the inc file for each wrapping
file. An additional prefix is added to the inc file to create multiple.
Compile definitions and include directories are no longer
obtained from the directory. This is replaced by usage of target level
properties.

Retain support for WRAPPER_LIBRARY_INCLUDE_DIRECTORIES and
WRAPPER_LIBRARY_LINK_LIBRARIES to control behavior.
For modules that use Python.h, explicitly include Python's path
for cast xml.
@blowekamp blowekamp force-pushed the fix_wrap_external branch from 9ecba99 to d63f5df Compare March 5, 2026 16:28
@blowekamp blowekamp merged commit a322c2d into InsightSoftwareConsortium:main Mar 5, 2026
2 of 4 checks passed
@thewtex
Copy link
Copy Markdown
Member

thewtex commented Mar 5, 2026

@blowekamp ok, thanks. I will cherry-pick all four patches on release. The ITK tag will stay the same, but the ITKPythonPackage will use the patched release. We will use this updated release hash for the Remote Module CI. You did a great job addressing most issues. I expect people will find a few more :-). The tag will be available, and we can suggest using main for the most up-to-date version.

thewtex pushed a commit that referenced this pull request Mar 6, 2026
Moves MeshRegion wrapping from ITKCommon to ITKMesh module and removes the workaround dependency linkage in TypedefMacros.cmake.

Related to PR #5842
thewtex pushed a commit that referenced this pull request Mar 6, 2026
Changes VTK Bridge module dependency from PRIVATE_DEPENDS to DEPENDS for ITKCommon, making it a public dependency as required.

Related to PR #5842
@thewtex
Copy link
Copy Markdown
Member

thewtex commented Mar 6, 2026

Backported to release.

hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 2, 2026
…tSoftwareConsortium#6191)

PR InsightSoftwareConsortium#5842 introduced $<LIST:JOIN,$<LIST:TRANSFORM,…>> generator
expressions in itk_auto_load_submodules.cmake. Those operators
landed in CMake 3.27 (2023-07) but ITK's cmake_minimum_required is
3.22.1; on older CMake they silently expand to empty at
file(GENERATE) time, producing castxml.inc files with no
-I/-isystem/-D flags and breaking Python wrapping.

Rewrite the three affected sites with $<JOIN:list,glue> (CMake
3.0+), carrying the per-element wrapping in the glue string and
guarded by $<$<BOOL:property>:…> so an empty property emits
nothing. Generated castxml.inc bytes are byte-identical to the
3.27+ form for both populated and empty target properties.

Revert when ITK's CMake floor reaches 3.27 (block comment marks
the lines).
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 2, 2026
…tSoftwareConsortium#6191)

PR InsightSoftwareConsortium#5842 introduced $<LIST:JOIN,$<LIST:TRANSFORM,…>> generator
expressions in itk_auto_load_submodules.cmake. Those operators
landed in CMake 3.27 (2023-07) but ITK's cmake_minimum_required is
3.22.1; on older CMake they silently expand to empty at
file(GENERATE) time, producing castxml.inc files with no
-I/-isystem/-D flags and breaking Python wrapping.

Rewrite the three affected sites with $<JOIN:list,glue> (CMake
3.0+), carrying the per-element wrapping in the glue string and
guarded by $<$<BOOL:property>:…> so an empty property emits
nothing. Generated castxml.inc bytes are byte-identical to the
3.27+ form for both populated and empty target properties.

Revert when ITK's CMake floor reaches 3.27 (block comment marks
the lines).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Bridge Issues affecting the Bridge module area:Core Issues affecting the Core module area:Python wrapping Python bindings for a class type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants