# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.

cmake_minimum_required(VERSION 3.12...3.31)
project(Polygon_mesh_processing_Examples)

# CGAL and its components
find_package(CGAL REQUIRED)

create_single_source_cgal_program("compute_normals_example_Polyhedron.cpp")
create_single_source_cgal_program("compute_normals_example.cpp")
create_single_source_cgal_program("connected_components_example.cpp")
create_single_source_cgal_program("detect_features_example.cpp")
create_single_source_cgal_program("face_filtered_graph_example.cpp")
create_single_source_cgal_program("hausdorff_bounded_error_distance_example.cpp")
create_single_source_cgal_program("list_non_pure_triangle_meshes.cpp" )
create_single_source_cgal_program("locate_example.cpp")
create_single_source_cgal_program("match_faces.cpp")
create_single_source_cgal_program("point_inside_example.cpp")
create_single_source_cgal_program("polyhedral_envelope.cpp" )
create_single_source_cgal_program("polyhedral_envelope_of_triangle_soup.cpp" )
create_single_source_cgal_program("polyhedral_envelope_mesh_containment.cpp" )
create_single_source_cgal_program("sample_example.cpp" )
create_single_source_cgal_program("self_intersections_example.cpp" )
create_single_source_cgal_program("volume_connected_components.cpp")

find_package(Eigen3 QUIET)
include(CGAL_Eigen3_support)

if(TARGET CGAL::Eigen3_support)
  create_single_source_cgal_program("interpolated_corrected_curvatures_SM.cpp")
  target_link_libraries(interpolated_corrected_curvatures_SM PRIVATE CGAL::Eigen3_support)
  create_single_source_cgal_program("interpolated_corrected_curvatures_PH.cpp")
  target_link_libraries(interpolated_corrected_curvatures_PH PRIVATE CGAL::Eigen3_support)
  create_single_source_cgal_program("interpolated_corrected_curvatures_vertex.cpp")
  target_link_libraries(interpolated_corrected_curvatures_vertex PRIVATE CGAL::Eigen3_support)
else()
  message(STATUS "NOTICE: Examples that use Eigen will not be compiled.")
endif()

find_package(OpenMesh QUIET)
if(OpenMesh_FOUND)
  include(CGAL_OpenMesh_support)

  create_single_source_cgal_program("compute_normals_example_OM.cpp")
  target_link_libraries(compute_normals_example_OM PRIVATE CGAL::OpenMesh_support)
  create_single_source_cgal_program("point_inside_example_OM.cpp")
  target_link_libraries(point_inside_example_OM PRIVATE CGAL::OpenMesh_support)
else()
  message(STATUS "NOTICE: Examples that use OpenMesh will not be compiled.")
endif()

find_package(METIS QUIET)
include(CGAL_METIS_support)
if(TARGET CGAL::METIS_support)
  target_link_libraries(hausdorff_bounded_error_distance_example PRIVATE CGAL::METIS_support)
else()
  message(STATUS "NOTICE: Examples that use the METIS library will not be compiled.")
endif()

find_package(TBB QUIET)
include(CGAL_TBB_support)
if(TARGET CGAL::TBB_support)
  target_link_libraries(self_intersections_example PRIVATE CGAL::TBB_support)
  target_link_libraries(hausdorff_bounded_error_distance_example PRIVATE CGAL::TBB_support)
else()
  message(STATUS "NOTICE: Intel TBB was not found. Sequential code will be used.")
endif()

find_package(Ceres QUIET)
include(CGAL_Ceres_support)
if(TARGET CGAL::Ceres_support)
  target_link_libraries(mesh_smoothing_example PRIVATE CGAL::Ceres_support)
else()
  message(STATUS "NOTICE: The example 'mesh_smoothing_example' uses the Ceres library, and will not be compiled.")
endif()
