Skip to content

Replace SlicerExecutionModel with a dcmqi-owned CLI generator - #569

Draft
fedorov wants to merge 4 commits into
masterfrom
remove-slicer-execution-model
Draft

fedorov wants to merge 4 commits into
masterfrom
remove-slicer-execution-model

Conversation

@fedorov

@fedorov fedorov commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

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

SEM piece Replacement
GenerateCLP (descriptor XML → <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 in apps/GenerateCLP/dcmqiCLP.h.
SEM's bundled TCLAP Upstream TCLAP 1.2.5 headers (MIT), unmodified, in tclap/. -DTCLAP_INCLUDE_DIR=<dir> builds against a system copy instead, e.g. Debian's libtclap-dev.
SEMMacroBuildCLI CMake/dcmqiMacroBuildCLI.cmake and CMake/dcmqiCLIExecutableWrapper.cxx
  • Unchanged files. No application .cxx or .xml file changes. The existing tests are also unchanged.

  • Superbuild. The superbuild no longer builds SEM: CMakeExternals/SlicerExecutionModel.cmake is removed, and DCMQIConfig.cmake no longer sets SlicerExecutionModel_DIR.

  • Build targets. dcmqiMacroBuildCLI creates the same targets as SEMMacroBuildCLI did:

    • <name>Lib, with main renamed to ModuleEntryPoint, so the test drivers link as before
    • the <name> executable
    • the XML copied next to the executable
  • Slicer extension builds. The macro reads the SlicerExecutionModel_DEFAULT_CLI_* and SlicerExecutionModel_USE_UTF8 variables that 3D Slicer sets. A Slicer extension build should therefore place the CLIs where it does today.

  • Strict generator. The generator accepts only the descriptor features dcmqi uses. It fails the build on anything else:

    • an unknown element or attribute
    • a missing, duplicate or reserved flag
    • a default that does not fit its parameter type

    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.h keeps the one-argument-per-line layout of the current binaries.

Verification (macOS arm64)

  • Behavior against dcmqi 1.5.7. 251 invocations of the 7 applications were compared with the dcmqi 1.5.7 wheel binaries. They cover --help, --xml, --echo, short, long and combined flags, repeated flags, missing values, unknown flags, and invalid enum and integer values.
  • Tests. ctest passes 111 of 111. That includes 30 new tests:
    • 11 descriptors that the generator must reject
    • per application: the --xml output, and an unknown flag
    • invalid enum and integer values
    • comma-separated lists and short flags
  • Packaging. The CPack tarball has the same file list as the 1.5.7 release tarball. The executables keep the same rpath.
  • No SEM left. A configured superbuild has no SEM project. The binaries contain no SEM symbols and link only system libraries.

Not yet verified (why this is a draft)

  • CI on Linux and Windows. GCC and MSVC have not compiled the new code yet; locally it builds cleanly under strict clang warnings.
  • A 3D Slicer extension build:
    • the CLIs land in cli-modules
    • Slicer discovers the modules
    • the QuantitativeReporting SEG and SR round trip works
  • Building against a system TCLAP. Only the vendored 1.2.5 has been tested.

Notes for reviewers

  • Building the apps against an installed dcmqi. The find_package(DCMQI) branch in the apps' CMakeLists.txt has no dcmqiMacroBuildCLI or generator available, because neither is exported. If that mode is still used, the macro and the generator need to be exported, or the branch removed.
  • Windows CI cache. The Windows dependency cache key hashes CMakeExternals/*.cmake. Removing the SEM file therefore causes one dependency rebuild on Windows.
  • ITK.cmake left as is. CMakeExternals/ITK.cmake still sets KWSYS_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.
  • Commit message count. The message of the second commit says "753 invocations". The correct number is 251; 753 is the number of recorded files (stdout, stderr and exit code per invocation).

🤖 Generated with Claude Code

fedorov and others added 4 commits November 13, 2026 21:57
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>
ubuntu-latest now resolves to Ubuntu 26.04, for which actions/setup-python
has no Python 3.10.11 build, so the job failed in its setup step before
building anything. Pin the image that the job last passed on.

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>
@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

This branch has not been deployed

No deployments
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.

1 participant