Skip to content

Commit

Permalink
improve detection of cases when Core can be used
Browse files Browse the repository at this point in the history
  • Loading branch information
sloriot committed Mar 14, 2024
1 parent 7a0f3da commit 44b7ec6
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CGAL_Core/include/CGAL/CORE/BigInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions Installation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 8 additions & 2 deletions Installation/lib/cmake/CGAL/CGALConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
21 changes: 3 additions & 18 deletions Number_types/include/CGAL/boost_mp_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 44b7ec6

Please sign in to comment.