From 05c3fc9e94f8a57329b210c1c429602e0d1f1264 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 Jun 2024 10:00:36 +0200 Subject: [PATCH 1/2] update CMakeLists.txt for recent VTK --- Mesh_3/examples/Mesh_3/CMakeLists.txt | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 6daadba75911..380202d4dff0 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -26,18 +26,14 @@ if(NOT TARGET CGAL::Eigen3_support) return() endif() -find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) +find_package(VTK + COMPONENTS ImagingGeneral IOImage + QUIET) if(VTK_FOUND) - if(VTK_USE_FILE) - include(${VTK_USE_FILE}) - endif() - if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) - message(STATUS "VTK found") - if(TARGET VTK::IOImage) - set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage) - endif() + if("${VTK_VERSION_MAJOR}" GREATER "8" OR VTK_VERSION VERSION_GREATER 8) + message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}") else() - message(STATUS "VTK version 6.0 or greater is required") + message(STATUS "VTK version 9.0 or greater is required") endif() else() message(STATUS "VTK was not found") @@ -123,13 +119,13 @@ create_single_source_cgal_program("mesh_polyhedral_complex_sm.cpp") target_link_libraries(mesh_polyhedral_complex_sm PUBLIC CGAL::Eigen3_support) if(TARGET CGAL::CGAL_ImageIO) - if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION - VERSION_GREATER 5)) + if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "8" OR VTK_VERSION + VERSION_GREATER 8)) create_single_source_cgal_program("mesh_3D_gray_vtk_image.cpp") - target_link_libraries( - mesh_3D_gray_vtk_image - PUBLIC CGAL::Eigen3_support CGAL::CGAL CGAL::CGAL_ImageIO ${VTK_LIBRARIES}) - cgal_add_test(mesh_3D_gray_vtk_image) + target_link_libraries(mesh_3D_gray_vtk_image + PUBLIC CGAL::Eigen3_support + CGAL::CGAL_ImageIO + PRIVATE ${VTK_LIBRARIES}) add_to_cached_list(CGAL_EXECUTABLE_TARGETS mesh_3D_gray_vtk_image) endif() From f3b409a807e539155199b32eaefd488338e5457b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 11 Jun 2024 15:57:25 +0200 Subject: [PATCH 2/2] require VTK version 9.0 or later --- BGL/test/BGL/CMakeLists.txt | 29 ++++++------------- Installation/CMakeLists.txt | 2 +- Lab/demo/Lab/Plugins/IO/CMakeLists.txt | 33 ++++++---------------- Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt | 18 ++---------- Mesh_3/examples/Mesh_3/CMakeLists.txt | 11 ++------ 5 files changed, 25 insertions(+), 68 deletions(-) diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index 3b4304b5056b..0d995ff281d8 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -66,26 +66,15 @@ else() message(STATUS "NOTICE: Tests that use OpenMesh will not be compiled.") endif() -find_package(VTK QUIET COMPONENTS vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources) -if (VTK_FOUND) - if(VTK_USE_FILE) - include(${VTK_USE_FILE}) - endif() - - if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) - if(TARGET VTK::CommonCore) - set(VTK_LIBRARIES VTK::CommonCore VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::FiltersCore VTK::FiltersSources) - endif() - - if(VTK_LIBRARIES) - target_link_libraries(test_bgl_read_write PRIVATE ${VTK_LIBRARIES}) - target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_VTK -DNOMINMAX) - target_link_libraries(test_deprecated_io PRIVATE ${VTK_LIBRARIES}) - target_compile_definitions(test_deprecated_io PRIVATE -DCGAL_USE_VTK -DNOMINMAX) - else() - message(STATUS "Tests that use VTK will not be compiled.") - endif() - endif() +find_package(VTK 9.0 QUIET COMPONENTS CommonCore IOCore IOLegacy IOXML FiltersCore FiltersSources) +if (VTK_FOUND AND VTK_LIBRARIES) + message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}") + target_link_libraries(test_bgl_read_write PRIVATE ${VTK_LIBRARIES}) + target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_VTK -DNOMINMAX) + target_link_libraries(test_deprecated_io PRIVATE ${VTK_LIBRARIES}) + target_compile_definitions(test_deprecated_io PRIVATE -DCGAL_USE_VTK -DNOMINMAX) +else() + message(STATUS "Tests that use VTK will not be compiled.") endif() #VTK_FOUND find_path(3MF_INCLUDE_DIR diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 98d27538371c..a44e7fb4cb54 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -934,7 +934,7 @@ if(CGAL_BRANCH_BUILD) find_package(Doxygen REQUIRED) find_package(Eigen3 REQUIRED) find_package(Qt6 COMPONENTS Core Widgets OpenGL Gui REQUIRED) - find_package(VTK COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) + find_package(VTK COMPONENTS ImagingGeneral IOImage NO_MODULE) if(VTK_FOUND) get_target_property(VTK_INCLUDE_DIRS VTK::IOImage INTERFACE_INCLUDE_DIRECTORIES) endif() diff --git a/Lab/demo/Lab/Plugins/IO/CMakeLists.txt b/Lab/demo/Lab/Plugins/IO/CMakeLists.txt index c6247c39212e..6ed225c04908 100644 --- a/Lab/demo/Lab/Plugins/IO/CMakeLists.txt +++ b/Lab/demo/Lab/Plugins/IO/CMakeLists.txt @@ -43,38 +43,23 @@ target_link_libraries(surf_io_plugin PUBLIC scene_surface_mesh_item) cgal_lab_plugin(lcc_io_plugin lcc_io_plugin KEYWORDS Viewer) target_link_libraries(lcc_io_plugin PUBLIC scene_lcc_item) -find_package(VTK QUIET COMPONENTS vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML - vtkFiltersCore vtkFiltersSources) +find_package(VTK 9.0 QUIET COMPONENTS CommonCore IOCore IOLegacy IOXML FiltersCore FiltersSources) set_package_properties( VTK PROPERTIES DESCRIPTION "A library for image processing." - PURPOSE "Can be used for I/O (DICOM, VTU, VTP.") + PURPOSE "Can be used for I/O (DICOM, VTU, VTP).") cgal_lab_plugin(triangulation_3_io_plugin triangulation_3_io_plugin KEYWORDS Viewer) target_link_libraries(triangulation_3_io_plugin PUBLIC scene_triangulation_3_item) -if(VTK_FOUND) - if(VTK_USE_FILE) - include(${VTK_USE_FILE}) - endif() - if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) - if(TARGET VTK::CommonCore) - set(VTK_LIBRARIES VTK::CommonCore VTK::IOCore VTK::IOLegacy VTK::IOXML - VTK::FiltersCore VTK::FiltersSources) - endif() - if(VTK_LIBRARIES) - cgal_lab_plugin(vtk_plugin VTK_io_plugin KEYWORDS Viewer Mesh_3) - target_link_libraries(vtk_plugin PUBLIC scene_surface_mesh_item scene_polylines_item scene_c3t3_item scene_points_with_normal_item - ${VTK_LIBRARIES}) - target_compile_definitions(vtk_plugin PRIVATE -DCGAL_USE_VTK -DNOMINMAX) - else() - message(STATUS "NOTICE: the vtk IO plugin needs VTK libraries and will not be compiled.") - endif() - else() - message(STATUS "NOTICE: the vtk IO plugin needs VTK 6.0 or greater and will not be compiled (incorrect version found).") - endif() +if(VTK_FOUND AND VTK_LIBRARIES) + message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}") + cgal_lab_plugin(vtk_plugin VTK_io_plugin KEYWORDS Viewer Mesh_3) + target_link_libraries(vtk_plugin PUBLIC scene_surface_mesh_item scene_polylines_item scene_c3t3_item scene_points_with_normal_item + ${VTK_LIBRARIES}) + target_compile_definitions(vtk_plugin PRIVATE -DCGAL_USE_VTK -DNOMINMAX) else() - message(STATUS "NOTICE: the vtk IO plugin needs VTK 6.0 or greater and will not be compiled.") + message(STATUS "NOTICE: the vtk IO plugin needs VTK 9.0 or greater and will not be compiled.") endif() cgal_lab_plugin(xyz_plugin XYZ_io_plugin KEYWORDS Viewer PointSetProcessing Classification) target_link_libraries(xyz_plugin PUBLIC scene_points_with_normal_item) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt b/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt index 1f681a39e2c6..2234d34db36d 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt +++ b/Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt @@ -37,21 +37,9 @@ if(ITK_FOUND) target_link_libraries(mesh_3_plugin PUBLIC CGAL::ITK_support) endif(ITK_FOUND) -find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage vtkIOXML NO_MODULE) -if(VTK_FOUND) - if(VTK_USE_FILE) - include(${VTK_USE_FILE}) - endif() - if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) - if(TARGET VTK::IOImage) - set(VTK_LIBRARIES VTK::IOImage VTK::ImagingGeneral VTK::IOXML) - endif() - if(NOT VTK_LIBRARIES) - message(STATUS "NOTICE: DICOM files (.dcm) require the VTK libraries, and will not be readable.") - endif() - else() - message(STATUS "NOTICE: DICOM files (.dcm) require the VTK libraries, and will not be readable.") - endif() +find_package(VTK 9.0 QUIET COMPONENTS ImagingGeneral IOImage IOXML NO_MODULE) +if(VTK_FOUND AND VTK_LIBRARIES) + message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}") else() message(STATUS "NOTICE: DICOM files (.dcm) require the VTK libraries, and will not be readable.") endif() diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 380202d4dff0..88aceb7c0682 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -26,15 +26,11 @@ if(NOT TARGET CGAL::Eigen3_support) return() endif() -find_package(VTK +find_package(VTK 9.0 COMPONENTS ImagingGeneral IOImage QUIET) if(VTK_FOUND) - if("${VTK_VERSION_MAJOR}" GREATER "8" OR VTK_VERSION VERSION_GREATER 8) - message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}") - else() - message(STATUS "VTK version 9.0 or greater is required") - endif() + message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}") else() message(STATUS "VTK was not found") endif() @@ -119,8 +115,7 @@ create_single_source_cgal_program("mesh_polyhedral_complex_sm.cpp") target_link_libraries(mesh_polyhedral_complex_sm PUBLIC CGAL::Eigen3_support) if(TARGET CGAL::CGAL_ImageIO) - if(VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "8" OR VTK_VERSION - VERSION_GREATER 8)) + if(VTK_FOUND) create_single_source_cgal_program("mesh_3D_gray_vtk_image.cpp") target_link_libraries(mesh_3D_gray_vtk_image PUBLIC CGAL::Eigen3_support