improve detection of cases when Core can be used

This commit is contained in:
Sébastien Loriot 2024-03-14 11:11:18 +01:00
parent 7a0f3da89b
commit 44b7ec6f3a
8 changed files with 46 additions and 28 deletions

View File

@ -30,7 +30,7 @@
#include <string>
#if !(defined(CGAL_CORE_USE_BOOST_BACKEND) && BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP))
#if !(defined(CGAL_CORE_USE_BOOST_BACKEND) && BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) && !defined(CGAL_DISABLE_GMP)
#define CGAL_CORE_USE_GMP_BACKEND 1
#endif

View File

@ -115,6 +115,9 @@ option(CGAL_ENABLE_TESTING "Build the testing tree." ${BUILD_TESTING})
endif()
endif(CGAL_BRANCH_BUILD)
#allow to force disabling boost multiprecision support
option(CGAL_DO_NOT_USE_BOOST_MP "Disable the support of boost multiprecision library" FALSE)
#message(STATUS "Packages found: ${CGAL_CONFIGURED_PACKAGES}")
list(SORT CGAL_CONFIGURED_PACKAGES_NAMES)

View File

@ -131,12 +131,6 @@ function(CGAL_setup_CGAL_flags target)
$<$<COMPILE_LANGUAGE:CXX>:/fp:except->
$<$<COMPILE_LANGUAGE:CXX>:/bigobj> # Use /bigobj by default
)
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.3)
message(STATUS "Apple Clang version ${CMAKE_CXX_COMPILER_VERSION} compiler detected")
message(STATUS "Boost MP is turned off for all Apple Clang versions below 11.0.3!")
target_compile_options(${target} INTERFACE "-DCGAL_DO_NOT_USE_BOOST_MP")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
message( STATUS "Using Intel Compiler. Adding -fp-model strict" )
if(WIN32)
@ -166,4 +160,9 @@ function(CGAL_setup_CGAL_flags target)
target_compile_options(${target} INTERFACE "-mieee" "-mfp-rounding-mode=d" )
endif()
endif()
if (CGAL_DO_NOT_USE_BOOST_MP)
target_compile_options(${target} INTERFACE "-DCGAL_DO_NOT_USE_BOOST_MP")
endif()
endfunction()

View File

@ -52,5 +52,4 @@ function(CGAL_setup_CGAL_Core_dependencies target)
use_CGAL_GMP_support(CGAL_Core INTERFACE)
target_compile_definitions(${target} INTERFACE CGAL_USE_CORE=1)
target_link_libraries( CGAL_Core INTERFACE CGAL::CGAL )
endfunction()

View File

@ -35,8 +35,32 @@
# endif // CGAL_USE_MPFR and no <mpfr.h>
#endif // __has_include
// It is easier to disable this number type completely for old versions.
// Before 1.63, I/O is broken. Again, disabling the whole file is just the
// easy solution.
// MSVC had trouble with versions <= 1.69:
// https://github.com/boostorg/multiprecision/issues/98
//
// Disable also on Windows 32 bits
// because CGAL/cpp_float.h assumes _BitScanForward64 is available
// See https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64
//
// Disable also with PowerPC processors, with Boost<1.80 because of that bug:
// https://github.com/boostorg/multiprecision/pull/421
//
#if !defined CGAL_DO_NOT_USE_BOOST_MP && \
(!defined _MSC_VER || BOOST_VERSION >= 107000) && \
(!defined _WIN32 || defined _WIN64) && \
(BOOST_VERSION >= 108000 || (!defined _ARCH_PPC && !defined _ARCH_PPC64))
#define CGAL_USE_BOOST_MP 1
#endif
#if CGAL_USE_BOOST_MP
#if ! CGAL_NO_CORE
# define CGAL_USE_CORE 1
#endif
#endif
#endif // CGAL_INTERNAL_ENABLE_THIRD_PARTY_LIBRARIES_H

View File

@ -127,12 +127,18 @@ if( CGAL_DEV_MODE OR RUNNING_CGAL_AUTO_TEST OR CGAL_TEST_SUITE )
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.3)
message(STATUS "Apple Clang version ${CMAKE_CXX_COMPILER_VERSION} compiler detected")
message(STATUS "Boost MP is turned off for all Apple Clang versions below 11.0.3!")
set(CGAL_DO_NOT_USE_BOOST_MP TRUE)
endif()
foreach(comp ${CGAL_FIND_COMPONENTS})
if(NOT comp MATCHES "Core|ImageIO|Qt6")
message(FATAL_ERROR "The requested CGAL component ${comp} does not exist!")
endif()
if(comp MATCHES "Core" AND CGAL_DISABLE_GMP)
message("CGAL_Core needs GMP and won't be used.")
if(comp MATCHES "Core" AND CGAL_DO_NOT_USE_BOOST_MP)
message("CGAL_Core needs Boost multiprecision support and won't be used.")
else()
list(APPEND CGAL_LIBRARIES CGAL_${comp})
endif()

View File

@ -23,7 +23,9 @@
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#ifdef CGAL_USE_BOOST_MP
#include <CGAL/cpp_float.h>
#endif
#ifdef CGAL_USE_GMP
# include <CGAL/Gmpz.h>

View File

@ -15,24 +15,9 @@
#include <CGAL/config.h>
#include <CGAL/number_utils.h>
// It is easier to disable this number type completely for old versions.
// Before 1.63, I/O is broken. Again, disabling the whole file is just the
// easy solution.
// MSVC had trouble with versions <= 1.69:
// https://github.com/boostorg/multiprecision/issues/98
//
// Disable also on Windows 32 bits
// because CGAL/cpp_float.h assumes _BitScanForward64 is available
// See https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64
//
// Disable also with PowerPC processors, with Boost<1.80 because of that bug:
// https://github.com/boostorg/multiprecision/pull/421
//
#if !defined CGAL_DO_NOT_USE_BOOST_MP && \
(!defined _MSC_VER || BOOST_VERSION >= 107000) && \
(!defined _WIN32 || defined _WIN64) && \
(BOOST_VERSION >= 108000 || (!defined _ARCH_PPC && !defined _ARCH_PPC64))
#define CGAL_USE_BOOST_MP 1
// CGAL_USE_BOOST_MP is defined in
// CGAL/Installation/internal/enable_third_party_libraries.h
#if CGAL_USE_BOOST_MP
#include <CGAL/Quotient.h>
#include <CGAL/functional.h> // *ary_function