Skip to content

cmtk: fix build with cmake 4#488619

Closed
colonelpanic8 wants to merge 2 commits intoNixOS:masterfrom
colonelpanic8:cmtk-cmake4
Closed

cmtk: fix build with cmake 4#488619
colonelpanic8 wants to merge 2 commits intoNixOS:masterfrom
colonelpanic8:cmtk-cmake4

Conversation

@colonelpanic8
Copy link
Copy Markdown
Contributor

@colonelpanic8 colonelpanic8 commented Feb 9, 2026

Summary

  • Fix cmtk build failure with cmake 4 (Tracking: Build Failures with CMake 4 #445447)
  • Remove EXPORT_LIBRARY_DEPENDENCIES call (removed in cmake 4, CMP0033) and its related install command. cmtk is a standalone tool, not consumed as a cmake dependency by other packages.
  • Add CMAKE_POLICY_VERSION_MINIMUM=3.5 to handle cmake_minimum_required(VERSION 2.8.12) in upstream CMakeLists.txt

This is a simpler alternative to draft PR #455098 which used a 267-line patch to modernize the export system. Since cmtk upstream is abandoned (last release 2016), removing the unused export is more appropriate than modernizing it.

Port of #445447

Test plan

  • nix-build -A cmtk succeeds
  • cmtk registration --help works
  • All binaries present in output
  • nixfmt passes

🤖 Generated with Claude Code

@colonelpanic8 colonelpanic8 reopened this Feb 9, 2026
@nixpkgs-ci nixpkgs-ci bot requested a review from tbenst February 9, 2026 08:49
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Feb 9, 2026
EXPORT_LIBRARY_DEPENDENCIES was removed in cmake 4 (CMP0033).
Remove the call and related install command since cmtk is a standalone
tool that is not consumed as a cmake dependency.

Also set CMAKE_POLICY_VERSION_MINIMUM=3.5 to handle
cmake_minimum_required(VERSION 2.8.12) in upstream CMakeLists.txt.

Fixes: NixOS#445447

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@Sigmanificient Sigmanificient left a comment

Choose a reason for hiding this comment

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

./result/bin/cmtk: line 49: /nix/store/vdmpr4hj0sav5mpvyxlvkqrbmqm6vkn7-cmtk-3.3.2/lib/cmtk/bin/: No such file or directory

@colonelpanic8
Copy link
Copy Markdown
Contributor Author

Addressed the wrapper issue reported in review.

Follow-up commit: be21f1f1b3c1 (cmtk: handle wrapper invocation without arguments).

Verification:

  • nix build .#cmtk -L
  • ./result/bin/cmtk now prints usage instead of trying to execute the private bin directory
  • ./result/bin/cmtk describe --help still works through the wrapper


cmakeFlags = [
(lib.cmakeFeature "CMAKE_CXX_STANDARD" "14")
# Upstream is abandoned (last release 2016) and uses cmake features
Copy link
Copy Markdown
Member

@Sigmanificient Sigmanificient Mar 19, 2026

Choose a reason for hiding this comment

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

It seems there is a new release for 3.4.0 dated from 2024. The archive format is a bit weird, but one that solved it still does not compile successfully.

If you want to give it a shot:

diff --git a/pkgs/by-name/cm/cmtk/package.nix b/pkgs/by-name/cm/cmtk/package.nix
index e08d6c1ae33f..7151664c7949 100644
--- a/pkgs/by-name/cm/cmtk/package.nix
+++ b/pkgs/by-name/cm/cmtk/package.nix
@@ -11,19 +11,17 @@
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "cmtk";
-  version = "3.3.2";
+  version = "3.4.0";
 
   src = fetchurl {
     name = "cmtk-source.tar.gz";
-    url = "https://www.nitrc.org/frs/download.php/13188/CMTK-${finalAttrs.version}-Source.tar.gz//?i_agree=1&download_now=1";
-    hash = "sha256-iE164NCOSOypZLLZfZy9RTyrS+YnY9ECqfb4QhlsMS4=";
+    url = "https://www.nitrc.org/frs/download.php/15655/CMTK-${finalAttrs.version}-Source.tar.gz//?i_agree=1&download_now=1";
+    hash = "sha256-FOBfFtv3XmGLeet/wT6phf/I4VjP2aY3Smya8z/MM24=";
   };
 
-  postPatch = ''
-    substituteInPlace apps/vtkxform.cxx --replace-fail \
-      "float xyzFloat[3] = { xyz[0], xyz[1], xyz[2] };" \
-      "float xyzFloat[3] = { (float)xyz[0], (float)xyz[1], (float)xyz[2] };"
+  sourceRoot = "usr/local";
 
+  postPatch = ''
     # EXPORT_LIBRARY_DEPENDENCIES was removed in cmake 4 (CMP0033).
     # Remove the call and related install since cmtk is a standalone tool.
     # https://github.com/NixOS/nixpkgs/issues/445447

Copy link
Copy Markdown
Member

@Sigmanificient Sigmanificient left a comment

Choose a reason for hiding this comment

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

Yeah it "works"... I do not particularly like the current state of that program tbh. It has been broken for a while now, has no maintainer and is accumulating patches just to get built.

I'm honestly thinking this package may not be worth the time investment, because of the poor maintenance of the upstream source 😅

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Mar 19, 2026
@mdaniels5757 mdaniels5757 mentioned this pull request Apr 5, 2026
13 tasks
@mdaniels5757
Copy link
Copy Markdown
Member

Thanks for this PR! But I agree with Sigmanificient: I don't think this package should be kept. (Indeed, the fact that no one has complained that the package is broken implies to me that no one is using this package. I don't think it's a good use of resources to maintain userless packages!)

Filed #506861

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants