opencascade-occt: add optional vtk dependency (#433252)

This commit is contained in:
Nick Cao
2025-09-04 20:17:19 -04:00
committed by GitHub
2 changed files with 40 additions and 4 deletions
+26 -4
View File
@@ -13,8 +13,12 @@
libXext,
libXmu,
libXi,
}:
vtk,
withVtk ? false,
# used in passthru.tests
opencascade-occt,
}:
stdenv.mkDerivation rec {
pname = "opencascade-occt";
version = "7.8.1";
@@ -33,6 +37,10 @@ stdenv.mkDerivation rec {
url = "https://github.com/Open-Cascade-SAS/OCCT/commit/7236e83dcc1e7284e66dc61e612154617ef715d6.diff";
hash = "sha256-NoC2mE3DG78Y0c9UWonx1vmXoU4g5XxFUT3eVXqLU60=";
})
# patch does not apply against 7.9+, it was submitted upstream for future
# inclusion: https://github.com/Open-Cascade-SAS/OCCT/pull/683
./vtk-draw-conditional-glx.patch
];
nativeBuildInputs = [
@@ -49,10 +57,25 @@ stdenv.mkDerivation rec {
libXmu
libXi
rapidjson
];
]
++ lib.optional withVtk vtk;
NIX_CFLAGS_COMPILE = [ "-fpermissive" ];
cmakeFlags = [ "-DUSE_RAPIDJSON=ON" ];
cmakeFlags = [
(lib.cmakeBool "USE_RAPIDJSON" true)
# Enable exception handling for release builds.
(lib.cmakeBool "BUILD_RELEASE_DISABLE_EXCEPTIONS" false)
]
++ lib.optionals withVtk [
(lib.cmakeBool "USE_VTK" true)
(lib.cmakeFeature "3RDPARTY_VTK_INCLUDE_DIR" "${lib.getDev vtk}/include/vtk")
];
passthru = {
tests = {
withVtk = opencascade-occt.override ({ withVtk = true; });
};
};
meta = with lib; {
description = "Open CASCADE Technology, libraries for 3D modeling and numerical simulation";
@@ -63,5 +86,4 @@ stdenv.mkDerivation rec {
maintainers = with maintainers; [ amiloradovsky ];
platforms = platforms.all;
};
}
@@ -0,0 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 86905287dc..19214e8f2d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -623,5 +623,9 @@ if (USE_VTK)
add_definitions (-DHAVE_VTK)
set (OCCT_VTK_USED_TARGETS "" CACHE INTERNAL "" FORCE)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
+ if (DEFINED VTK_USE_X AND NOT VTK_USE_X)
+ message (STATUS "Info: TKIVtkDraw toolkits excluded due to VTK has no glx support")
+ list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw)
+ endif()
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")