From 490996e66d36829394e01c19089385f23fdf3c9c Mon Sep 17 00:00:00 2001
From: Daeho Ro <40587651+daeho-ro@users.noreply.github.com>
Date: Thu, 30 Apr 2026 19:13:45 +0900
Subject: [PATCH] Add x11 on linux when vtk 9.6+

---
 visualization/CMakeLists.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/visualization/CMakeLists.txt b/visualization/CMakeLists.txt
index 4d775081248..5259b8bc537 100644
--- a/visualization/CMakeLists.txt
+++ b/visualization/CMakeLists.txt
@@ -140,6 +140,11 @@ endif()
 
 target_link_libraries("${LIB_NAME}" pcl_common pcl_io pcl_kdtree pcl_geometry pcl_search ${OPENGL_LIBRARIES})
 
+if(${VTK_VERSION} VERSION_GREATER_EQUAL 9.6 AND UNIX AND NOT ANDROID AND NOT APPLE AND NOT APPLE_IOS)
+  find_package(X11 REQUIRED)
+  target_link_libraries("${LIB_NAME}" ${X11_LIBRARIES})
+endif()
+
 if(${VTK_VERSION} VERSION_GREATER_EQUAL 9.0)
   #Some libs are referenced through depending on IO
   target_link_libraries("${LIB_NAME}"
