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

Fixes when neither LEDA nor GMP is available #7960

Merged
merged 18 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
9 changes: 9 additions & 0 deletions Arithmetic_kernel/include/CGAL/Arithmetic_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ typedef GMP_arithmetic_kernel Arithmetic_kernel;
#endif // CGAL_USE_GMP
#endif // CGAL_HAS_DEFAULT_ARITHMETIC_KERNEL

#ifndef CGAL_HAS_DEFAULT_ARITHMETIC_KERNEL
#include <CGAL/BOOST_MP_arithmetic_kernel.h>
#if defined(CGAL_HAS_BOOST_MP_ARITHMETIC_KERNEL)
namespace CGAL{
typedef BOOST_cpp_arithmetic_kernel Arithmetic_kernel;
}// namespace CGAL
#define CGAL_HAS_DEFAULT_ARITHMETIC_KERNEL 1
#endif // CGAL_USE_BOOST_MP
#endif // CGAL_HAS_DEFAULT_ARITHMETIC_KERNEL

// Macro to snap typedefs in Arithmetic_kernel
#define CGAL_SNAP_ARITHMETIC_KERNEL_TYPEDEFS(AT) \
Expand Down
2 changes: 2 additions & 0 deletions Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
//#include <boost/multiprecision/gmp.hpp>
//#endif

#define CGAL_HAS_BOOST_MP_ARITHMETIC_KERNEL

// FIXME: the could be several kernels based on Boost.Multiprecision.

namespace CGAL {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,24 @@ if(CGAL_DISABLE_GMP)
endif()

if(CGAL_DISABLE_GMP)
message(STATUS "GMP is disable. Try to use LEDA instead.")
set(GMPZ_NT ${LEDA_INT_NT})
set(QUOTIENT_CGAL_GMPZ_NT ${LEDA_RAT_NT})
set(CGAL_GMPQ_NT ${LEDA_RAT_NT})
set(LAZY_CGAL_GMPQ_NT ${LAZY_LEDA_RAT_NT})
set(LAZY_GMPZ_NT ${LAZY_LEDA_RAT_NT})
set(CGAL_GMPZ_NT ${LEDA_INT_NT})
message(STATUS "GMP is disable.")
sloriot marked this conversation as resolved.
Show resolved Hide resolved
if (CGAL_USE_LEDA)
message(STATUS "Try to use LEDA instead.")
sloriot marked this conversation as resolved.
Show resolved Hide resolved
set(GMPZ_NT ${LEDA_INT_NT})
set(QUOTIENT_CGAL_GMPZ_NT ${LEDA_RAT_NT})
set(CGAL_GMPQ_NT ${LEDA_RAT_NT})
set(LAZY_CGAL_GMPQ_NT ${LAZY_LEDA_RAT_NT})
set(LAZY_GMPZ_NT ${LAZY_LEDA_RAT_NT})
set(CGAL_GMPZ_NT ${LEDA_INT_NT})
else()
message(STATUS "Try to use MP float instead.")
set(GMPZ_NT ${MP_FLOAT_NT})
set(QUOTIENT_CGAL_GMPZ_NT ${QUOTIENT_MP_FLOAT_NT})
set(CGAL_GMPQ_NT ${QUOTIENT_MP_FLOAT_NT})
set(LAZY_CGAL_GMPQ_NT ${LAZY_QUOTIENT_MP_FLOAT_NT})
set(LAZY_GMPZ_NT ${LAZY_QUOTIENT_MP_FLOAT_NT})
set(CGAL_GMPZ_NT ${MP_FLOAT_NT})
endif()
endif()

set(COMPARE 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,24 @@ CORE_INT_NT=15
CORE_RAT_NT=16

if [ -n "${CGAL_DISABLE_GMP}" ]; then
echo GMP is disable. Try to use LEDA instead.
GMPZ_NT=$LEDA_INT_NT
QUOTIENT_CGAL_GMPZ_NT=$LEDA_RAT_NT
CGAL_GMPQ_NT=$LEDA_RAT_NT
LAZY_CGAL_GMPQ_NT=$LAZY_LEDA_RAT_NT
LAZY_GMPZ_NT=$LAZY_LEDA_RAT_NT
CGAL_GMPZ_NT=$LEDA_INT_NT
echo GMP is disable.
if [ -n "CGAL_USE_LEDA" ]; then
echo Try to use LEDA instead.
GMPZ_NT=$LEDA_INT_NT
QUOTIENT_CGAL_GMPZ_NT=$LEDA_RAT_NT
CGAL_GMPQ_NT=$LEDA_RAT_NT
LAZY_CGAL_GMPQ_NT=$LAZY_LEDA_RAT_NT
LAZY_GMPZ_NT=$LAZY_LEDA_RAT_NT
CGAL_GMPZ_NT=$LEDA_INT_NT
else
echo Try to use MP float instead.
GMPZ_NT=$MP_FLOAT_NT
QUOTIENT_CGAL_GMPZ_NT=$QUOTIENT_MP_FLOAT_NT
CGAL_GMPQ_NT=$QUOTIENT_MP_FLOAT_NT
LAZY_CGAL_GMPQ_NT=$LAZY_QUOTIENT_MP_FLOAT_NT
LAZY_GMPZ_NT=$LAZY_QUOTIENT_MP_FLOAT_NT
CGAL_GMPZ_NT=$MP_FLOAT_NT
fi
sloriot marked this conversation as resolved.
Show resolved Hide resolved
fi

COMPARE=1
Expand Down
19 changes: 4 additions & 15 deletions Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core)
find_package(LEDA QUIET)

if(CGAL_Core_FOUND OR LEDA_FOUND)
if(MSVC)
# Turn off a boost related warning that appears with VC2015
# boost_1_65_1\boost\graph\named_function_params.hpp(240) :
# warning C4172: returning address of local variable or temporary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4172")
endif()

# create a target per cppfile
file(
GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}")
endforeach()
create_single_source_cgal_program("compute_cones.cpp")
create_single_source_cgal_program("theta_io.cpp")
else()
message("NOTICE: This program requires the CGAL_Core library (or LEDA), and will not be compiled.")
endif()

create_single_source_cgal_program("dijkstra_theta.cpp")
20 changes: 12 additions & 8 deletions Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ cmake_minimum_required(VERSION 3.1...3.23)
project(Cone_spanners_2_Tests)

find_package(CGAL REQUIRED COMPONENTS Core)
find_package(LEDA QUIET)

# create a target per cppfile
file(
GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}")
endforeach()
create_single_source_cgal_program("cones_inexact.cpp")
create_single_source_cgal_program("theta_inexact.cpp")
create_single_source_cgal_program("yao_inexact.cpp")

if(CGAL_Core_FOUND OR LEDA_FOUND)
Comment on lines 7 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is strange. find_package(CGAL REQUIRED COMPONENTS Core) should stop the compilation if Core is not found. That is certainly an error in CGALConfig.cmake.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can open an independent issue if we want to fix that. OPTIONAL keyword should indeed be used.

create_single_source_cgal_program("cones_exact.cpp")
create_single_source_cgal_program("theta_exact.cpp")
create_single_source_cgal_program("yao_exact.cpp")
else()
message("NOTICE: Some tests require the CGAL_Core library (or LEDA), and will not be compiled.")
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ cmake_minimum_required(VERSION 3.1...3.23)
project(Hyperbolic_triangulation_2_Examples)

find_package(CGAL REQUIRED COMPONENTS Core)
find_package(LEDA QUIET)

create_single_source_cgal_program("ht2_example.cpp")
create_single_source_cgal_program("ht2_example_color.cpp")
if (CGAL_Core_FOUND OR LEDA_FOUND)
create_single_source_cgal_program("ht2_example.cpp")
create_single_source_cgal_program("ht2_example_color.cpp")
else()
message("NOTICE: Examples require CGAL_Core (or LEDA), and will not be compiled.")
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ cmake_minimum_required(VERSION 3.1...3.23)
project(Hyperbolic_triangulation_2_Tests)

find_package(CGAL REQUIRED COMPONENTS Core)
find_package(LEDA QUIET)

create_single_source_cgal_program("ht2_test_clear.cpp")
create_single_source_cgal_program("ht2_test_locate.cpp")
create_single_source_cgal_program("ht2_test_remove.cpp")
create_single_source_cgal_program("ht2_test_swap.cpp")
create_single_source_cgal_program("ht2_test_copy.cpp")
create_single_source_cgal_program("ht2_test_hyperbolic_circulator.cpp")
create_single_source_cgal_program("ht2_test_insert_degenerate.cpp")
if (CGAL_Core_FOUND OR LEDA_FOUND)
create_single_source_cgal_program("ht2_test_clear.cpp")
create_single_source_cgal_program("ht2_test_locate.cpp")
create_single_source_cgal_program("ht2_test_remove.cpp")
create_single_source_cgal_program("ht2_test_swap.cpp")
create_single_source_cgal_program("ht2_test_copy.cpp")
create_single_source_cgal_program("ht2_test_hyperbolic_circulator.cpp")
create_single_source_cgal_program("ht2_test_insert_degenerate.cpp")
else()
message("NOTICE: Tests require CGAL_Core (or LEDA), and will not be compiled.")
endif()
9 changes: 8 additions & 1 deletion Kernel_23/test/Kernel_23/test_Has_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Simple_homogeneous.h>
#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA)
#include <CGAL/Exact_predicates_exact_constructions_kernel_with_kth_root.h>
#endif
#include <CGAL/Filtered_kernel.h>

#include <CGAL/Has_conversion.h>
Expand All @@ -36,13 +38,16 @@ int main()
typedef CGAL::Simple_homogeneous<NT_exact> SH;
typedef CGAL::Filtered_kernel<SH> FSH;

#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA)
typedef CGAL::Exact_predicates_exact_constructions_kernel_with_kth_root EPECK;
CGAL_USE_TYPE(EPECK);
#endif

CGAL_USE_TYPE(ASC);
CGAL_USE_TYPE(FSC);
CGAL_USE_TYPE(SH);
CGAL_USE_TYPE(FSH);
CGAL_USE_TYPE(EPECK);


assert((CGAL::Has_conversion<SC, SC, SC::Point_2, SC::Point_2>::value));
assert((CGAL::Has_conversion<SC, SC, SC::Object_2, SC::Object_2>::value));
Expand All @@ -55,10 +60,12 @@ int main()
assert((CGAL::Has_conversion<SH, FSH, SH::Vector_3, FSH::Vector_3>::value));

assert((CGAL::Has_conversion<SC, ASC, SC::Sphere_3, ASC::Sphere_3>::value));
#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA)
assert((CGAL::Has_conversion<SC, EPECK, SC::Triangle_2, EPECK::Triangle_2>::value));
assert((CGAL::Has_conversion<EPECK, SC, EPECK::Circle_3, SC::Circle_3>::value));

assert(!(CGAL::Has_conversion<SC, EPECK, SC::Weighted_point_2, EPECK::Weighted_point_3>::value));
#endif
assert(!(CGAL::Has_conversion<SC, ASC, SC::Point_2, ASC::Weighted_point_2>::value));

// below will produce static assert failures
Expand Down
9 changes: 2 additions & 7 deletions Nef_S2/test/Nef_S2/Nef_polyhedron_S2-test.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#include <CGAL/Homogeneous.h>
#include <CGAL/Nef_polyhedron_S2.h>
#include <CGAL/test_macros.h>
#include <CGAL/Exact_integer.h>

#ifdef CGAL_USE_LEDA
#include <CGAL/leda_integer.h>
typedef leda_integer NT;
#else
#include <CGAL/Gmpz.h>
typedef CGAL::Gmpz NT;
#endif
typedef CGAL::Exact_integer NT;

typedef CGAL::Homogeneous<NT> Kernel;
typedef CGAL::Nef_polyhedron_S2<Kernel> Nef_polyhedron;
Expand Down
5 changes: 5 additions & 0 deletions Number_types/test/Number_types/to_interval_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
#include <CGAL/Gmpz.h>
#endif


#include <CGAL/float.h>
#include <CGAL/double.h>
#include <CGAL/int.h>

#if 0
#ifdef CGAL_USE_CLN
#include <CGAL/CLN/cl_integer.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK;
typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK;
//typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK;

typedef CGAL::Surface_mesh<EPICK::Point_3> EPICK_SM;
typedef CGAL::Surface_mesh<EPECK::Point_3> EPECK_SM;
//typedef CGAL::Surface_mesh<EPECK::Point_3> EPECK_SM;

namespace PMP = CGAL::Polygon_mesh_processing;

Expand Down Expand Up @@ -100,8 +100,8 @@ void test(const Mesh& mesh,
{
if (PMP::is_degenerate_triangle_face(f, mesh))
{
if (std::is_same<K, EPECK>())
assert(get(fnormals, f) == CGAL::NULL_VECTOR);
// if (std::is_same<K, EPECK>())
// assert(get(fnormals, f) == CGAL::NULL_VECTOR);
}
else
assert(get(fnormals, f) != CGAL::NULL_VECTOR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
//#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
#include <CGAL/Surface_mesh.h>

#include <CGAL/draw_straight_skeleton_2.h>
Expand Down
35 changes: 23 additions & 12 deletions Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,34 @@ cmake_minimum_required(VERSION 3.1...3.23)
project(Straight_skeleton_2_Tests)

find_package(CGAL REQUIRED COMPONENTS Qt6 Core)
find_package(LEDA QUIET)

include_directories(BEFORE "include")

# create a target per cppfile
file(
GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}")
endforeach()
create_single_source_cgal_program("issue4533.cpp")
create_single_source_cgal_program("issue4684.cpp")
create_single_source_cgal_program("test_sls.cpp")
create_single_source_cgal_program("test_sls_previous_issues.cpp")
create_single_source_cgal_program("test_sls_traits.cpp")
create_single_source_cgal_program("test_straight_skeleton_copy.cpp")

if(CGAL_Qt6_FOUND)
target_link_libraries(issue4684 PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(issue7149 PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(issue7284 PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_previous_issues PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_offset PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_weighted_polygons_with_holes PUBLIC CGAL::CGAL_Basic_viewer)
endif()

if (CGAL_Core_FOUND OR LEDA_FOUND)
create_single_source_cgal_program("test_sls_offset.cpp")
create_single_source_cgal_program("issue7284.cpp")
create_single_source_cgal_program("test_sls_simple.cpp")
create_single_source_cgal_program("test_sls_weighted_polygons_with_holes.cpp")
create_single_source_cgal_program("issue7149.cpp")
if(CGAL_Qt6_FOUND)
target_link_libraries(issue7149 PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(issue7284 PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_offset PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_weighted_polygons_with_holes PUBLIC CGAL::CGAL_Basic_viewer)
endif()
else()
message("NOTICE: Some test require CGAL_Core (or LEDA), and will not be compiled.")
Comment on lines +12 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a more flexible way possible?
(see e.g. https://github.com/doxygen/doxygen/blob/master/examples/CMakeLists.txt and look for BASIC_EXAMPLES. still a list but a bit more flexible, maybe something is possible here as well...)

endif()
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ cmake_minimum_required(VERSION 3.1...3.23)
project(Straight_skeleton_extrusion_2_Tests)

find_package(CGAL REQUIRED COMPONENTS Qt6 Core)
find_package(LEDA QUIET)

include_directories(BEFORE "include")

# create a target per cppfile
file(
GLOB cppfiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}")
endforeach()

if(CGAL_Qt6_FOUND)
target_link_libraries(test_sls_extrude PUBLIC CGAL::CGAL_Basic_viewer)
if (CGAL_Core_FOUND OR LEDA_FOUND)
create_single_source_cgal_program("test_sls_extrude.cpp")
if(CGAL_Qt6_FOUND)
target_link_libraries(test_sls_extrude PUBLIC CGAL::CGAL_Basic_viewer)
endif()
else()
message("NOTICE: Tests require CGAL_Core (or LEDA), and will not be compiled.")
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ cmake_minimum_required(VERSION 3.1...3.23)
project( Triangulation_on_sphere_2_Examples )

find_package(CGAL REQUIRED COMPONENTS Core)
find_package(LEDA QUIET)

create_single_source_cgal_program( "triang_on_sphere.cpp" )
create_single_source_cgal_program( "triang_on_sphere_range.cpp" )
create_single_source_cgal_program( "triang_on_sphere_exact.cpp" )
create_single_source_cgal_program( "triang_on_sphere_proj.cpp" )
create_single_source_cgal_program( "triang_on_sphere_geo.cpp" )

if (CGAL_Core_FOUND OR LEDA_FOUND)
create_single_source_cgal_program( "triang_on_sphere_exact.cpp" )
else()
message("NOTICE: Some tests require CGAL_Core (or LEDA), and will not be compiled.")
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ cmake_minimum_required(VERSION 3.1...3.23)
project( Triangulation_on_sphere_2_Tests )

find_package(CGAL REQUIRED COMPONENTS Core)
find_package(LEDA QUIET)

create_single_source_cgal_program( "test_dtos.cpp" )
create_single_source_cgal_program( "test_dtos2_remove.cpp" )
create_single_source_cgal_program( "test_dtos_degenerate_cases.cpp" )
create_single_source_cgal_program( "test_dtos_illegal_points.cpp" )
create_single_source_cgal_program( "test_dtos_projection_traits.cpp" )
create_single_source_cgal_program( "test_dtos_traits.cpp" )

if (CGAL_Core_FOUND OR LEDA_FOUND)
create_single_source_cgal_program( "test_dtos_degenerate_cases.cpp" )
else()
message("NOTICE: Some tests require CGAL_Core (or LEDA), and will not be compiled.")
endif()

find_package(Eigen3 3.1.0 QUIET) #(requires 3.1.0 or greater)
include(CGAL_Eigen3_support)
if(TARGET CGAL::Eigen3_support)
Expand Down