diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 20e216cf540..dc376906f02 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -30,7 +30,7 @@ #include -#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 diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index fa2102ff7c0..6335ead8411 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -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) diff --git a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake index 1d51bbbdac5..347ab99e71c 100644 --- a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake @@ -131,12 +131,6 @@ function(CGAL_setup_CGAL_flags target) $<$:/fp:except-> $<$:/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() diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake index 44be800f9c0..17e0dd01738 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake @@ -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() diff --git a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h index f241cc6130c..461a41707d1 100644 --- a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h +++ b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h @@ -35,8 +35,32 @@ # endif // CGAL_USE_MPFR and no #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 diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index 93e9e8830f0..5f54f9aad34 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -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() diff --git a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h index 772200e7b72..d29278219dc 100644 --- a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h +++ b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h @@ -23,7 +23,9 @@ #include #include +#ifdef CGAL_USE_BOOST_MP #include +#endif #ifdef CGAL_USE_GMP # include diff --git a/Number_types/include/CGAL/boost_mp_type.h b/Number_types/include/CGAL/boost_mp_type.h index ae65fb6d3ba..cf18678c011 100644 --- a/Number_types/include/CGAL/boost_mp_type.h +++ b/Number_types/include/CGAL/boost_mp_type.h @@ -15,24 +15,9 @@ #include #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 +// CGAL_USE_BOOST_MP is defined in +// CGAL/Installation/internal/enable_third_party_libraries.h +#if CGAL_USE_BOOST_MP #include #include // *ary_function