diff --git a/Installation/cmake/modules/CGAL_ITK_support.cmake b/Installation/cmake/modules/CGAL_ITK_support.cmake new file mode 100644 index 00000000000..61ed67e2f2b --- /dev/null +++ b/Installation/cmake/modules/CGAL_ITK_support.cmake @@ -0,0 +1,7 @@ +if(ITK_FOUND AND NOT TARGET CGAL::ITK_support) + add_library(CGAL::ITK_support INTERFACE IMPORTED) + set_target_properties(CGAL::ITK_support PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "CGAL_USE_ITK" + INTERFACE_INCLUDE_DIRECTORIES "${ITK_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${ITK_LIBRARIES}") +endif() diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index aff10c6037b..aa5d716253f 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -164,10 +164,10 @@ if(TARGET CGAL::CGAL_ImageIO) find_package(ITK QUIET COMPONENTS ITKCommon ITKThresholding ITKSmoothing ITKImageIntensity) if(ITK_FOUND) - include(${ITK_USE_FILE}) + include(CGAL_ITK_support) create_single_source_cgal_program("mesh_3D_weighted_image.cpp") target_link_libraries(mesh_3D_weighted_image - PUBLIC CGAL::Eigen3_support ${ITK_LIBRARIES}) + PUBLIC CGAL::Eigen3_support CGAL::ITK_support) endif(ITK_FOUND) else() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt index df7f4c7ee35..89d05476c46 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt @@ -30,9 +30,8 @@ target_include_directories(mesh_3_plugin PRIVATE include) find_package(ITK QUIET COMPONENTS ITKCommon ITKThresholding ITKSmoothing ITKImageIntensity) if(ITK_FOUND) - include(${ITK_USE_FILE}) - target_link_libraries(mesh_3_plugin PUBLIC ${ITK_LIBRARIES}) - target_compile_definitions(mesh_3_plugin PUBLIC CGAL_USE_ITK) + include(CGAL_ITK_support) + target_link_libraries(mesh_3_plugin PUBLIC CGAL::ITK_support) endif(ITK_FOUND) find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE)