Repository navigation
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
🟡 Changes recommended
Missing Slicer ITK factory initialization breaks conversion I/O, while missing factory linkage and include paths prevent Slicer test drivers from building.
6 open issues
Initialize ITK IO factories in Slicer CLI builds · New Link ITKFactoryRegistration into Slicer test drivers · New Restore standalone app builds using the installed package · New Install the bundled TCLAP license notice · New Forward the host generator path through the superbuild · New Normalize validated integer defaults to decimal · New
What changed in this PR
This PR replaces SlicerExecutionModel with dcmqi-owned command-line generation and build support, removing a licensing obstacle to Debian main while aiming to preserve existing application interfaces.
Changes:
- Adds a strict XML-to-C++ generator, shared parsing helpers, and CLI compatibility tests.
- Replaces SEM build integration with dcmqi CMake support and upstream MIT-licensed TCLAP headers.
- Documents third-party licensing and adjusts CI configuration.
| File | Description |
|---|---|
| tclap/tclap/ZshCompletionOutput.h | Adds upstream shell-completion output. |
| tclap/tclap/XorHandler.h | Adds mutually exclusive argument handling. |
| tclap/tclap/Visitor.h | Adds the argument visitor interface. |
| tclap/tclap/VersionVisitor.h | Adds version-output handling. |
| tclap/tclap/ValuesConstraint.h | Adds allowed-value validation. |
| tclap/tclap/ValueArg.h | Adds single-value argument parsing. |
| tclap/tclap/UnlabeledValueArg.h | Adds positional argument parsing. |
| tclap/tclap/UnlabeledMultiArg.h | Adds repeated positional arguments. |
| tclap/tclap/SwitchArg.h | Adds boolean switch parsing. |
| tclap/tclap/StdOutput.h | Adds standard help and error output. |
| tclap/tclap/StandardTraits.h | Adds string parsing traits. |
| tclap/tclap/sstream.h | Adds stream compatibility support. |
| tclap/tclap/OptionalUnlabeledTracker.h | Adds positional argument ordering checks. |
| tclap/tclap/MultiSwitchArg.h | Adds counting switches. |
| tclap/tclap/MultiArg.h | Adds repeated value arguments. |
| tclap/tclap/IgnoreRestVisitor.h | Adds end-of-options handling. |
| tclap/tclap/HelpVisitor.h | Adds help-output handling. |
| tclap/tclap/DocBookOutput.h | Adds upstream DocBook output. |
| tclap/tclap/Constraint.h | Adds the value constraint interface. |
| tclap/tclap/CmdLineOutput.h | Adds the parser output interface. |
| tclap/tclap/CmdLineInterface.h | Adds the command-line parser interface. |
| tclap/tclap/CmdLine.h | Adds the upstream parser implementation. |
| tclap/tclap/ArgTraits.h | Adds argument type traits. |
| tclap/tclap/ArgException.h | Adds parsing exception types. |
| tclap/tclap/Arg.h | Adds shared argument functionality. |
| tclap/README.md | Documents provenance and system-header selection. |
| tclap/COPYING | Includes TCLAP’s MIT license. |
| SuperBuild.cmake | Removes SEM from dependencies. |
| README.md | Documents bundled third-party licenses. |
| CMakeLists.txt | Configures TCLAP and removes SEM package settings. |
| CMakeExternals/SlicerExecutionModel.cmake | Removes the SEM external project. |
| CMake/dcmqiTest.cmake | Updates test-driver dependencies and include precedence. |
| CMake/dcmqiMacroBuildCLI.cmake | Adds CLI generation, build, and installation support. |
| CMake/DCMQIConfig.cmake.in | Removes the exported SEM directory. |
| CMake/dcmqiCLIUTF8.manifest | Adds Windows UTF-8 process configuration. |
| CMake/dcmqiCLIExecutableWrapper.cxx | Adds the executable entry-point wrapper. |
| apps/sr/CMakeLists.txt | Switches SR applications to the new macro. |
| apps/seg/CMakeLists.txt | Switches SEG applications to the new macro. |
| apps/paramaps/CMakeLists.txt | Switches parametric-map applications to the new macro. |
| apps/GenerateCLP/Testing/dcmqiCheckCommand.cmake | Adds command-result and output checks. |
| apps/GenerateCLP/Testing/CMakeLists.txt | Adds descriptor rejection and CLI tests. |
| apps/GenerateCLP/dcmqiGenerateCLP.cxx | Implements descriptor validation and header generation. |
| apps/GenerateCLP/dcmqiCLP.h | Adds shared parsing, help, and echo support. |
| apps/GenerateCLP/CMakeLists.txt | Defines the generator and host-tool override. |
| apps/CMakeLists.txt | Integrates the generator and its tests. |
| .github/workflows/cmake-win.yml | Adds a build-step identifier. |
| .github/workflows/cmake-macos.yml | Adds a build-step identifier. |
| .github/workflows/cmake-linux.yml | Pins the runner to Ubuntu 24.04. |
Review effort: Balanced
|
|
||
| int main(int argc, char* argv[]) | ||
| { | ||
| return ModuleEntryPoint(argc, argv); |
There was a problem hiding this comment.
Confirmed, and fixed in 483cf42. In a Slicer build, dcmqiMacroBuildCLI now uses the same three variables SEMMacroBuildCLI used:
- Wrapper. The executable is built from Slicer's wrapper,
SlicerExecutionModel_CLI_LIBRARY_WRAPPER_CXX, which callsitk::itkFactoryRegistration()beforeModuleEntryPoint. It is compiled withMODULE_STATIC, since<name>Libis static. - Include directories.
SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIESis added to the executable. - Libraries. The executable links
SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES.
Standalone builds still use dcmqiCLIExecutableWrapper.cxx and get no ITKFactoryRegistration dependency.
Verification so far is limited to a stub CMake project. It used Slicer's SEMCommandLineLibraryWrapper.cxx.in unchanged, stand-in variables and a stand-in ITKFactoryRegistration library. There, the factories were registered before the application ran. A real Slicer extension build is still pending.
| # The test drivers include the application source, so they must see the | ||
| # same TCLAP headers as ${_SELF_MODULE_NAME}Lib even if the including | ||
| # project has another copy of TCLAP on its include path. | ||
| target_include_directories(${_name} BEFORE PRIVATE ${DCMQI_TCLAP_INCLUDE_DIR}) |
There was a problem hiding this comment.
Confirmed, and fixed in 483cf42. dcmqi_add_test_executable links SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES again, and also adds SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES. Those were previously inherited from SEMMacroBuildCLI's directory-level include_directories().
In the stub project described in the other thread, the test driver compiled with HAS_ITK_FACTORY_REGISTRATION and linked ITKFactoryRegistration. A real Slicer extension build is still pending.
| if(NOT TARGET dcmqiGenerateCLP) | ||
| message(FATAL_ERROR "dcmqiMacroBuildCLI: the dcmqiGenerateCLP target is not defined") |
There was a problem hiding this comment.
Retired in c1ce745: the find_package(DCMQI) branches are removed from apps/seg, apps/paramaps and apps/sr. The applications are now built only as part of dcmqi, either standalone or as a Slicer extension. Nothing builds them separately against an installed dcmqi, so exporting the generator and macro for that mode didn't seem worth the extra public surface.
| set(DCMQI_TCLAP_INCLUDE_DIR ${TCLAP_INCLUDE_DIR}) | ||
| message(STATUS "${_msg} - no") | ||
| else() | ||
| set(DCMQI_TCLAP_INCLUDE_DIR ${DCMQI_SOURCE_DIR}/tclap) |
There was a problem hiding this comment.
Fixed in 1d024f1. Two notices are now installed to ${DCMQI_INSTALL_DOC_DIR} (doc/) in the RuntimeLibraries component, which is what the CPack packages contain:
LICENSE.txttclap/COPYINGasTCLAP-COPYING.txt, when the bundled TCLAP is used
Slicer extension packaging is left unchanged. The CI packages for 6167719 contain doc/LICENSE.txt and doc/TCLAP-COPYING.txt. Checked on Linux x64, macOS arm64 and Windows.
| set(DCMQI_GENERATECLP_EXECUTABLE "" CACHE FILEPATH | ||
| "dcmqiGenerateCLP executable to run during the build instead of building it (for cross-compiling)") | ||
| mark_as_advanced(DCMQI_GENERATECLP_EXECUTABLE) |
There was a problem hiding this comment.
Fixed in df209c6. DCMQI_GENERATECLP_EXECUTABLE is now declared in the top-level CMakeLists.txt, before the superbuild branch, and marked with mark_as_superbuild(DCMQI_GENERATECLP_EXECUTABLE:FILEPATH).
A superbuild configured with -DDCMQI_GENERATECLP_EXECUTABLE=/opt/host/dcmqiGenerateCLP now has it in the inner build's initial cache:
set(DCMQI_GENERATECLP_EXECUTABLE "/opt/host/dcmqiGenerateCLP" CACHE FILEPATH ...)
| || value > INT_MAX) | ||
| { | ||
| throw DescriptorError(context + ": <default> must be an integer"); | ||
| } |
There was a problem hiding this comment.
Confirmed, and fixed in 11b712c. After validation, the generator replaces the default with the parsed value (std::to_string), so the descriptor text is no longer copied into the generated code.
The new test dcmqiGenerateCLP_generates_integerDefaultDecimal uses a default of +008:
- The generated header must contain
int x = 8;andfalse, 8, "int". - The old generator wrote
+008, which fails to compile with "invalid digit '8' in octal constant". The test fails against it.
The generated headers of all 7 dcmqi descriptors are unchanged.
Add the unmodified include/tclap/ directory of tclap-1.2.5.tar.gz (SHA-256 bb649f76dae35e8d0dcba4b52acfd4e062d787e6a81b43f7a4b01275153165a6) with its MIT license, for the command-line parsing code of the dcmqi applications. tclap/README.md records the provenance; the README lists TCLAP and JsonCpp as the third-party code in the source tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SlicerExecutionModel is under the 3D Slicer license, which Debian does not consider DFSG-free (Slicer/SlicerExecutionModel#159), and it was the only such dependency of dcmqi. Replace the parts dcmqi used with code written for dcmqi, without copying from SlicerExecutionModel: - apps/GenerateCLP/dcmqiGenerateCLP.cxx: build-time tool that reads an application's XML descriptor and writes <name>CLP.h with the PARSE_ARGS macro. It uses only the C++ standard library (no DCMTK, no Python) and accepts only the descriptor features dcmqi uses, failing the build on anything else. - apps/GenerateCLP/dcmqiCLP.h: runtime support shared by the generated headers, on top of the vendored TCLAP. - CMake/dcmqiMacroBuildCLI.cmake: replaces SEMMacroBuildCLI with the same targets (<name>Lib with main renamed ModuleEntryPoint, <name>, XML next to the executable) and honors the SlicerExecutionModel_DEFAULT_CLI_* variables that 3D Slicer sets for extension builds. The applications' sources and XML descriptors are unchanged, and so is their command-line behavior: --xml, --help, --echo, error messages and exit codes match dcmqi 1.5.7 on a corpus of 753 invocations. TCLAP_INCLUDE_DIR selects a system TCLAP instead of the vendored one. Add tests for the generator's rejection of unsupported descriptors and for the applications' --xml output and argument errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cache save steps run only when steps.build.outcome is 'success', but no step had the id 'build', so the condition was never true and the DCMTK, ITK and zlib builds were never saved. Each run that missed the cache rebuilt them from scratch. Give the build steps that id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tid1500reader and tid1500writer failed to link with MSVC: their main() takes "char** argv", which MSVC decorates differently from the "char* argv[]" declared by the executable wrapper, although the two are the same type. GCC and Clang decorate both the same way. Declare ModuleEntryPoint extern "C" in dcmqiCLP.h, which every application includes before main(), and in the wrapper. The symbol then no longer depends on how an application spells argv. The application sources are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dcmqi 1.5.7 Windows package has the Microsoft C/C++ runtime DLLs (vcruntime140*, msvcp140*, concrt140) in bin/, next to the executables; SlicerExecutionModel's build macro installed them. Without them the applications do not start on systems that lack the Visual C++ Redistributable. dcmqiMacroBuildCLI now includes InstallRequiredSystemLibraries once, with the executables' install destination and the RuntimeLibraries component that CPack packages. Packages on other platforms are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
081c493 to
4299a61
Compare
3D Slicer turns off ITK's automatic IO factory registration and supplies, through SlicerConfig.cmake, a main() wrapper that calls itk::itkFactoryRegistration() before the application, together with the ITKFactoryRegistration include directories and library. SEMMacroBuildCLI used all three; dcmqiMacroBuildCLI and the test drivers ignored them, so the applications built as a Slicer extension could not read or write images, and the test drivers, which call itkFactoryRegistration() when the target exists, would not link. Use SlicerExecutionModel_CLI_LIBRARY_WRAPPER_CXX, _EXTRA_INCLUDE_DIRECTORIES and _EXTRA_EXECUTABLE_TARGET_LIBRARIES when they are defined. Standalone builds are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The option was declared in apps/GenerateCLP, which only the inner build reaches, and the superbuild did not pass it on. Setting it on the top-level configure, as a cross-compile would, had no effect: the inner build compiled a dcmqiGenerateCLP for the target, which cannot run on the build host. Declare it in the top-level CMakeLists.txt and mark it for the superbuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dcmqiGenerateCLP validated an integer <default> with strtol(..., 10) but wrote the original text into the generated code, where a leading zero makes the literal octal: "010" became 8 and "08" did not compile. Write the parsed value instead. None of the dcmqi descriptors is affected; their generated headers are unchanged. Add a test that checks the generated header for such a default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The applications compile in the bundled TCLAP, whose MIT license requires its notice in copies of the software, but the packages, which contain the RuntimeLibraries component, shipped no license file at all. Install LICENSE.txt, and tclap/COPYING as TCLAP-COPYING.txt when the bundled TCLAP is used, into the doc directory of that component. Slicer extension packaging is left as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
apps/seg, apps/paramaps and apps/sr called find_package(DCMQI) when configured on their own, against an installed dcmqi. That relied on the package exporting SlicerExecutionModel; the installed package does not provide dcmqiGenerateCLP or dcmqiMacroBuildCLI, so the configuration no longer works. Nothing builds it, so remove it: the applications are built as part of dcmqi, standalone or as a Slicer extension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"module" is a keyword in C++20 modules (SonarCloud cpp:S1669). Also use std::size for the size of ParameterKinds (cpp:S7127). No change to the generated headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
SlicerExecutionModel (SEM) is distributed under the 3D Slicer license. Debian does not consider that license DFSG-free (Slicer/SlicerExecutionModel#159). SEM is dcmqi's only dependency with this problem, so it is what keeps dcmqi out of Debian
main.This PR replaces the parts of SEM that dcmqi uses with code written for dcmqi. The applications' command-line interface does not change. The new code was written from the observed behavior of the dcmqi 1.5.7 binaries. Nothing was copied from SEM.
What changes
<name>CLP.h)apps/GenerateCLP/dcmqiGenerateCLP.cxx, a build-time tool that needs only the C++ standard library. Code shared by all generated headers is inapps/GenerateCLP/dcmqiCLP.h.tclap/.-DTCLAP_INCLUDE_DIR=<dir>builds against a system copy instead, e.g. Debian'slibtclap-dev.SEMMacroBuildCLICMake/dcmqiMacroBuildCLI.cmakeandCMake/dcmqiCLIExecutableWrapper.cxxUnchanged files. No application
.cxxor.xmlfile changes. The existing tests are also unchanged.Superbuild. The superbuild no longer builds SEM:
CMakeExternals/SlicerExecutionModel.cmakeis removed, andDCMQIConfig.cmakeno longer setsSlicerExecutionModel_DIR.Build targets.
dcmqiMacroBuildCLIcreates the same targets asSEMMacroBuildCLIdid:<name>Lib, withmainrenamed toModuleEntryPoint, so the test drivers link as before<name>executableSlicer extension builds. The macro reads the
SlicerExecutionModel_DEFAULT_CLI_*andSlicerExecutionModel_USE_UTF8variables that 3D Slicer sets. A Slicer extension build should therefore place the CLIs where it does today.SEMMacroBuildCLIdid, the macro then builds each executable from Slicer's wrapper (SlicerExecutionModel_CLI_LIBRARY_WRAPPER_CXX), which callsitk::itkFactoryRegistration(). It also addsSlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIESandSlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES. The test drivers get the same include directories and libraries.License notices. The packages now include
doc/LICENSE.txtand, when the bundled TCLAP is used,doc/TCLAP-COPYING.txt, as TCLAP's MIT license requires. Slicer extension packaging is unchanged.Standalone app builds removed.
apps/seg,apps/paramapsandapps/srcan no longer be configured on their own against an installed dcmqi. That mode needed SEM from the installed package, and nothing builds it.Cross-compiling.
-DDCMQI_GENERATECLP_EXECUTABLE=<host dcmqiGenerateCLP>is passed through the superbuild to the inner build.Strict generator. The generator accepts only the descriptor features dcmqi uses. It fails the build on anything else:
Integer defaults are written to the generated code as plain decimal, so a default such as
010cannot turn into an octal literal.A future XML edit therefore can't silently change behavior.
No Python or DCMTK. Python is not needed at build time or at runtime. The generator does not link DCMTK, so it also runs when DCMTK is built as shared libraries, as in Slicer extension builds on Windows.
Help layout. Upstream TCLAP wraps the usage block at 75 columns.
dcmqiCLP.hkeeps the one-argument-per-line layout of the current binaries.Verification (macOS arm64)
--help,--xml,--echo, short, long and combined flags, repeated flags, missing values, unknown flags, and invalid enum and integer values.itkimage2paramap.xmlanditkimage2segimage.xmlafter 1.5.7 (Support multiframe source images in SEG and PM conversion #558).--xmlprints each repository XML byte for byte.ctestpasses 111 of 111. That includes 30 new tests:--xmloutput, and an unknown flagNot yet verified (why this is a draft)
ITKFactoryRegistrationlibrary.cli-modulesNotes for reviewers
CMakeExternals/*.cmake. Removing the SEM file therefore causes one dependency rebuild on Windows.ITK.cmakeleft as is.CMakeExternals/ITK.cmakestill setsKWSYS_USE_MD5, with a comment saying SEM requires it. The Linux and macOS cache keys hash that file, so the file is left alone here.🤖 Generated with Claude Code