Skip to content

COMP: Build against ITK 6 - #45

Merged
hjmjohnson merged 3 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:itk6-compat
Sep 24, 2026
Merged

hjmjohnson merged 3 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:itk6-compat

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Build against ITK 6 while keeping ITK 5.4: take the C++ standard from ITK_CXX_STANDARD (only when the caller has not set one) so castxml parses ITK 6 headers as C++17, and use ITK_DISALLOW_COPY_AND_MOVE.

Why the standard mattered

The module pinned CMAKE_CXX_STANDARD to 14 before find_package(ITK). ITK 6's imported targets compile the library as C++17 regardless, but the wrapping reads CMAKE_CXX_STANDARD to pick castxml's -std, so castxml parsed ITK 6 headers as C++14 and failed on std::is_convertible_v in itkSmartPointer.h.

Verification

Configured with ITK_DIR pointing at an installed ITK 6 tree (upstream main as of 2026-09-22, ITK_WRAP_PYTHON=ON), built the module and its Python wrapping, and imported the wrapped module from Python. The module still builds against ITK 5.4.

Two changes, both of which keep the module building against ITK 5.4 as well.

The module pinned CMAKE_CXX_STANDARD to 14 before find_package(ITK). ITK 6
carries its own requirement on its imported targets, so the module's library
compiled as C++17 regardless, but the wrapping subdirectory reads
CMAKE_CXX_STANDARD directly to pick castxml's -std flag. castxml then parsed
ITK 6 headers as C++14 and failed on std::is_convertible_v in
itkSmartPointer.h. Take the standard from ITK_CXX_STANDARD, which both 5.4
and 6 export, and only when the caller has not already chosen one.

ITK 6 also turns ITK_DISALLOW_COPY_AND_ASSIGN into a static assertion asking
for ITK_DISALLOW_COPY_AND_MOVE, which ITK 5.4 defines as well.
@hjmjohnson
hjmjohnson marked this pull request as ready for review September 22, 2026 16:05
Pinned to a raw commit SHA from before ITKRemoteModuleBuildTestPackageAction
had version tags, which carries a runner-image matrix
(ubuntu-20.04, macos-11) that GitHub has since retired, failing every
job at VM allocation. v5.4.4 is the latest tagged release, matching what
sibling remote modules already use.
InsightSoftwareConsortium/ITKClangFormatLinterAction renamed its default
branch from master to main, so @master no longer resolves and the lint
job fails before running. Also bumps actions/checkout from the
deprecated v2 to v4, matching sibling remote modules.
@hjmjohnson
hjmjohnson merged commit bc60f01 into InsightSoftwareConsortium:main Sep 24, 2026
21 of 22 checks passed
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.

2 participants