From 26b22725e401bbd74bfacec0591d7426c9bccc5b Mon Sep 17 00:00:00 2001
From: Spiros Tsalikis <spiros.tsalikis@kitware.com>
Date: Mon, 4 Mar 2024 09:58:45 -0500
Subject: [PATCH] Add VTK::catalyst module

---
 CMakeLists.txt                                | 20 ++++++++++++-------
 .../docs/build_instructions/build_settings.md |  4 ++--
 IO/CatalystConduit/CMakeLists.txt             |  9 ---------
 IO/CatalystConduit/Catalyst/CMakeLists.txt    |  2 +-
 IO/CatalystConduit/vtk.module                 |  1 +
 Utilities/Catalyst/CMakeLists.txt             |  5 +++++
 Utilities/Catalyst/vtk.module                 |  5 +++++
 7 files changed, 27 insertions(+), 19 deletions(-)
 create mode 100644 Utilities/Catalyst/CMakeLists.txt
 create mode 100644 Utilities/Catalyst/vtk.module

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ecc672ea390..e9df704d3e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -228,7 +228,7 @@ endif ()
 
 #-----------------------------------------------------------------------------
 # Add an option to enable/disable catalyst2 support.
-option(VTK_ENABLE_CATALYST "Build IOCatalystConduit module and VTK catalyst implementation." OFF)
+option(VTK_ENABLE_CATALYST "Build catalyst-dependent modules, including the VTK catalyst implementation." OFF)
 mark_as_advanced(VTK_ENABLE_CATALYST)
 
 #-----------------------------------------------------------------------------
@@ -302,17 +302,23 @@ endif ()
 if (VTK_ENABLE_LOGGING)
   list(APPEND vtk_requested_modules
     VTK::loguru)
-  set("_vtk_module_reason_VTK::loguru"
-    "via `VTK_ENABLE_LOGGING`")
+else ()
+  list(APPEND vtk_rejected_modules
+    VTK::loguru)
 endif ()
+set("_vtk_module_reason_VTK::loguru"
+  "via `VTK_ENABLE_LOGGING`")
 if (VTK_ENABLE_CATALYST)
+  list(APPEND vtk_requested_modules
+    VTK::catalyst)
+  # This is kept because it may be how users are enabling the module today.
   list(APPEND vtk_requested_modules
     VTK::IOCatalystConduit)
-else()
+else ()
   list(APPEND vtk_rejected_modules
-    VTK::IOCatalystConduit)
-endif()
-set("_vtk_module_reason_VTK::IOCatalystConduit"
+    VTK::catalyst)
+endif ()
+set("_vtk_module_reason_VTK::catalyst"
   "via `VTK_ENABLE_CATALYST`")
 if (VTK_ENABLE_WEBGPU)
   list(APPEND vtk_requested_modules
diff --git a/Documentation/docs/build_instructions/build_settings.md b/Documentation/docs/build_instructions/build_settings.md
index 377e0392e3f..29970cb1092 100644
--- a/Documentation/docs/build_instructions/build_settings.md
+++ b/Documentation/docs/build_instructions/build_settings.md
@@ -35,8 +35,8 @@ Less common, but variables which may be of interest to some:
     will be implemented by default. Must be either `Sequential`, `STDThread`,
     `OpenMP` or `TBB`. The backend can be changed at runtime if the desired
     backend has his option `VTK_SMP_ENABLE_<backend_name>` set to `ON`.
-  * `VTK_ENABLE_CATALYST` (default `OFF`): Enable the CatlystConduit module
-  and build the VTK Catalyst implementation. Depends on an external Catalyst.
+  * `VTK_ENABLE_CATALYST` (default `OFF`): Enable catalyst-dependent modules
+    including the VTK catalyst implementation. Depends on an external Catalyst.
 
 OpenGL-related options:
 
diff --git a/IO/CatalystConduit/CMakeLists.txt b/IO/CatalystConduit/CMakeLists.txt
index 3b4ae8be56e..ca5cb1f1440 100644
--- a/IO/CatalystConduit/CMakeLists.txt
+++ b/IO/CatalystConduit/CMakeLists.txt
@@ -4,17 +4,8 @@ set(classes
   vtkConduitToDataObject
   vtkDataObjectToConduit)
 
-# SDK component is required for Catalyst implementation (see Catalyst subdir)
-vtk_module_find_package(PACKAGE catalyst VERSION 2.0 COMPONENTS SDK)
-
-set_property(GLOBAL PROPERTY vtk_catalyst_dir_primary "${catalyst_DIR}")
-
 vtk_module_add_module(VTK::IOCatalystConduit
   CLASSES ${classes})
 
-vtk_module_link(VTK::IOCatalystConduit
-  PUBLIC
-    catalyst::catalyst)
-
 vtk_add_test_mangling(VTK::IOCatalystConduit)
 add_subdirectory(Catalyst)
diff --git a/IO/CatalystConduit/Catalyst/CMakeLists.txt b/IO/CatalystConduit/Catalyst/CMakeLists.txt
index f4858f85334..87d0c688138 100644
--- a/IO/CatalystConduit/Catalyst/CMakeLists.txt
+++ b/IO/CatalystConduit/Catalyst/CMakeLists.txt
@@ -27,7 +27,7 @@ catalyst_implementation(
     "${catalyst_library_destination}"
   SOURCES
     VTKCatalyst.cxx
-  CATALYST_TARGET catalyst::catalyst)
+  CATALYST_TARGET VTK::catalyst)
 
 add_library(VTK::catalyst-vtk ALIAS catalyst-vtk)
 
diff --git a/IO/CatalystConduit/vtk.module b/IO/CatalystConduit/vtk.module
index c67f5a099d5..3e7a2699d64 100644
--- a/IO/CatalystConduit/vtk.module
+++ b/IO/CatalystConduit/vtk.module
@@ -13,6 +13,7 @@ SPDX_COPYRIGHT_TEXT
 DEPENDS
   VTK::CommonDataModel
   VTK::CommonExecutionModel
+  VTK::catalyst
 PRIVATE_DEPENDS
   VTK::FiltersCore
   VTK::FiltersAMR
diff --git a/Utilities/Catalyst/CMakeLists.txt b/Utilities/Catalyst/CMakeLists.txt
new file mode 100644
index 00000000000..4ebb1eccf24
--- /dev/null
+++ b/Utilities/Catalyst/CMakeLists.txt
@@ -0,0 +1,5 @@
+vtk_module_third_party_external(
+  PACKAGE catalyst
+  COMPONENTS SDK
+  TARGETS catalyst::catalyst
+  VERSION "2.0")
diff --git a/Utilities/Catalyst/vtk.module b/Utilities/Catalyst/vtk.module
new file mode 100644
index 00000000000..da29d31822b
--- /dev/null
+++ b/Utilities/Catalyst/vtk.module
@@ -0,0 +1,5 @@
+NAME
+  VTK::catalyst
+LIBRARY_NAME
+  vtkcatalyst
+THIRD_PARTY
-- 
GitLab