Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CMakeLists.txt for recent VTK to fix CMake Warning #8279

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions BGL/test/BGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Installation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
33 changes: 9 additions & 24 deletions Lab/demo/Lab/Plugins/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 3 additions & 15 deletions Lab/demo/Lab/Plugins/Mesh_3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
27 changes: 9 additions & 18 deletions Mesh_3/examples/Mesh_3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down