CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.95k stars 1.38k forks source link

Ubuntu still requires gmp regardless of CMAKE flags #8567

Open petrasvestartas opened 9 hours ago

petrasvestartas commented 9 hours ago

Issue Details

I set CMake flags but code still requires gmp, why? The CMAKE code below is enough for mac and windows but not ubuntu. Please help!


  SET(CGAL_CMAKE_EXACT_NT_BACKEND BOOST_BACKEND CACHE STRING "")
  SET(CGAL_DISABLE_GMP ON CACHE BOOL "")
  SET(CMAKE_DISABLE_FIND_PACKAGE_GMP ON CACHE BOOL "")

Source Code

https://github.com/petrasvestartas/wood/blob/main/install_ubuntu.sh

Environment

mering commented 8 hours ago

Same for us: We set CGAL_DISABLE_GMP to ON and define CGAL_NO_GMP but get the following building error with CGAL 6.0.1, Boost 1.86.0 and LLVM 18:

llvm/bin/../include/c++/v1/__type_traits/is_constructible.h:22:79: error: incomplete type 'boost::multiprecision::backends::gmp_int' used in type trait expression
   22 | struct _LIBCPP_TEMPLATE_VIS is_constructible : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {};
      |                                                                               ^
boost/libs/multiprecision/include/boost/multiprecision/detail/number_base.hpp:162:20: note: in instantiation of template class 'std::is_constructible<boost::multiprecision::backends::gmp_int, boost::multiprecision::backends::gmp_int>' requested here
  162 |           && (std::is_constructible<typename Num::backend_type, typename detail::canonical<T, typename Num::backend_type>::type>::value 
      |                    ^
boost/libs/multiprecision/include/boost/multiprecision/detail/default_ops.hpp:3953:1: note: in instantiation of template class 'boost::multiprecision::is_compatible_arithmetic_type<boost::multiprecision::number<boost::multiprecision::backends::gmp_int>, boost::multiprecision::number<boost::multiprecision::backends::gmp_int>>' requested here
 3953 | BINARY_OP_FUNCTOR(gcd, number_kind_integer)
      | ^
boost/libs/multiprecision/include/boost/multiprecision/detail/default_ops.hpp:3599:12: note: expanded from macro 'BINARY_OP_FUNCTOR'
 3599 |            is_compatible_arithmetic_type<Arithmetic, number<Backend, et_on> >::value && (number_category<Backend>::value == category),                                                                                                                     \
      |            ^
cgal/include/CGAL/CORE/BigInt.h:151:10: note: while substituting deduced template arguments into function template 'gcd' [with Backend = boost::multiprecision::backends::gmp_int, Arithmetic = BigInt]
  151 |   return boost::multiprecision::gcd(a,b);
      |          ^
boost/libs/multiprecision/include/boost/multiprecision/fwd.hpp:106:17: note: forward declaration of 'boost::multiprecision::backends::gmp_int'
  106 |          struct gmp_int;
      |                 ^
sloriot commented 8 hours ago

@petrasvestartas Are you using CGAL 6.0.x or 5.6.1?

mering commented 8 hours ago

FYI: For us this error appeared when trying to upgrade from 5.6.1 to 6.0.1. In 5.6.1 we didn't have problems with the same setup.

sloriot commented 8 hours ago

If I'm doing: CGAL_DIR=~/CGAL/releases/CGAL-6.0.1 cmake -DCGAL_DISABLE_GMP=ON ~/CGAL/releases/CGAL-6.0.1/examples/Triangulation_2 && make info_insert_with_pair_iterator_2

it compiles and if I get not gmp linked:

$ ldd info_insert_with_pair_iterator_2 
    linux-vdso.so.1 (0x00007fff78bad000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007febaa800000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007febaa721000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007febaaa43000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007febaa540000)
    /lib64/ld-linux-x86-64.so.2 (0x00007febaab0f000)

Could you both give it a try and let me know what you have?

mering commented 7 hours ago

We run CMake from Bazel.

We use the following configuration:

BUILD.bazel ```bazel load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") load("@rules_license//rules:license.bzl", "license") package( default_applicable_licenses = [":license"], default_visibility = ["//visibility:public"], ) exports_files(["LICENSE"]) license( name = "license", package_name = "cgal", license_kinds = [ "@rules_license//licenses/generic:by_exception_only", ], ) RESTRICTED_CGAL_PACKAGES = [ "Advancing_front_surface_reconstruction", "Algebraic_kernel_d", "Algebraic_kernel_for_circles", "Algebraic_kernel_for_spheres", "Alpha_shapes_2", "Alpha_shapes_3", "Apollonius_graph_2", "Arrangement_on_surface_2", "Barycentric_coordinates_2", "Boolean_set_operations_2", "Bounding_volumes", "CGAL_ipelets", "Circular_kernel_2", "Circular_kernel_3", "Classification", "Combinatorial_map", "Convex_hull_d", "Envelope_2", "Envelope_3", "Generalized_map", "GraphicsView", "Heat_method_3", "Hyperbolic_triangulation_2", "Inscribed_areas", "Interpolation", "Interval_skip_list", "Jet_fitting_3", "Linear_cell_complex", "Matrix_search", "Minkowski_sum_2", "Minkowski_sum_3", "Miscellany", "Nef_2", "Nef_3", "Nef_S2", "NewKernel_d", "OpenNL", "Optimal_bounding_box", "Optimal_transportation_reconstruction_2", "Optimisation_basic", "Partition_2", "Periodic_2_triangulation_2", "Periodic_3_mesh_3", "Periodic_3_triangulation_3", "Periodic_4_hyperbolic_triangulation_2", "Point_set_2", "Point_set_3", "Point_set_processing_3", "Poisson_surface_reconstruction_3", "Polygonal_surface_reconstruction", "Polyline_simplification_2", "Polynomial", "Polytope_distance_d", "Ridges_3", "Scale_space_reconstruction_3", "Segment_Delaunay_graph_2", "Segment_Delaunay_graph_Linf_2", "Set_movable_separability_2", "Shape_detection", "Skin_surface_3", "Snap_rounding_2", "Straight_skeleton_2", "Stream_lines_2", "Surface_mesh_approximation", "Surface_mesh_deformation", "Surface_mesh_parameterization", "Surface_mesh_segmentation", "Surface_mesh_shortest_path", "Surface_mesh_skeletonization", "Surface_mesh_topology", "Tetrahedral_remeshing", "Three", "Triangulation", "Visibility_2", "Voronoi_diagram_2", ] filegroup( name = "cgal_allowed_files", srcs = glob(["**"], exclude = ["%s/**" % x for x in RESTRICTED_CGAL_PACKAGES], ), visibility = ["//visibility:public"], ) # Shows a standard library using the Ninja generator cmake( name = "cgal", build_args = [ "-j4", ], cache_entries = { "BUILD_SHARED_LIBS": "OFF", "CGAL_DISABLE_GMP": "ON", "WITH_CGAL_Qt5": "OFF", "WITH_demos": "OFF", "WITH_examples": "OFF", }, defines = [ "CGAL_USE_CORE", "CGAL_HEADER_ONLY", "CGAL_EIGEN3_ENABLED", "CGAL_USE_OPENMESH", "CGAL_NO_GMP", "CGAL_NO_MPFR", ], env = { "CMAKE_BUILD_TYPE": "Release", "CMAKE_BUILD_PARALLEL_LEVEL": "4", }, lib_source = ":cgal_allowed_files", out_headers_only = True, deps = [ "@com_gitlab_libeigen_eigen//:eigen", "@openmesh", "@onetbb//:tbb", "@org_boost//:boost", ], install_args = [ "--component", "Unspecified", ], ) ```
MODULE.bazel ```bazel bazel_dep(name = "toolchains_llvm", version = "1.1.2") use_repo(non_module_deps, "com_googleapis_storage_chrome_linux_amd64_sysroot") # Inspect supported toolchains at https://github.com/bazel-contrib/toolchains_llvm/blob/master/toolchain/internal/llvm_distributions.bzl llvm = use_extension( "@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True, ) llvm.toolchain( llvm_version = "18.1.4", ) llvm.sysroot( label = "@com_googleapis_storage_chrome_linux_amd64_sysroot//:all_files", targets = ["linux-x86_64"], ) use_repo(llvm, "llvm_toolchain") register_toolchains( "@llvm_toolchain//:all", dev_dependency = True, ) bazel_dep(name = "rules_cc", version = "0.0.10") bazel_dep(name = "rules_foreign_cc", version = "0.10.1") ```

Is there anything which looks suspicious to you or where you need additional info?

sloriot commented 7 hours ago

@mering, is it what you use to "install" CGAL? The cmake option -DCGAL_DISABLE=ON must be provided to all compilation units using CGAL. That is nothing is hardcoded in the installed version of CGAL (it is a simple copy)

petrasvestartas commented 6 hours ago

@sloriot

I have just tried with 6.0.1 - same problem. 1 year ago, there was no problem, so I suspect that CGAL is not catching my OS: Ubuntu 24.04.1 LTS

These flags works on windows and mac, but not ubuntu:

  set(CGAL_CMAKE_EXACT_NT_BACKEND BOOST_BACKEND CACHE STRING "")
  set(CGAL_DISABLE_GMP ON CACHE BOOL "Disable GMP in CGAL")
  set(CMAKE_DISABLE_FIND_PACKAGE_GMP ON CACHE BOOL "Disable find package GMP in CMake")

@sloriot If you have ubuntu, could try to run this bash file, it suppose it to work just by drag and drop in your terminal: https://github.com/petrasvestartas/wood/blob/main/install_ubuntu.sh

This .cpp break the compilation with gmp:

image

Source file: https://github.com/petrasvestartas/wood/blob/2c841fb0632b1cd789676eb0bc6899ae75f6648b/cmake/src/wood/include/cgal_mesh_boolean.cpp#L4

It uses:

#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
mering commented 6 hours ago

@mering, is it what you use to "install" CGAL? The cmake option -DCGAL_DISABLE=ON must be provided to all compilation units using CGAL. That is nothing is hardcoded in the installed version of CGAL (it is a simple copy)

@sloriot What do you mean by "install". This basically runs cmake with the specified cache_entries, and then uses ninja to build and install into a specific directory and copies the cgal library from there.