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 6daadba75911..88aceb7c0682 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -26,19 +26,11 @@ if(NOT TARGET CGAL::Eigen3_support) return() endif() -find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) +find_package(VTK 9.0 + 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() - else() - message(STATUS "VTK version 6.0 or greater is required") - endif() + message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}") else() message(STATUS "VTK was not found") endif() @@ -123,13 +115,12 @@ 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) 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()