Skip to content

COMP: Build against ITK 6 - #45

Open
hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:itk6-compat
Open

hjmjohnson wants to merge 1 commit 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
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