2 include(CheckCXXSourceCompiles)
4 set(_save_required_libraries ${CMAKE_REQUIRED_LIBRARIES})
5 set(_save_required_includes ${CMAKE_REQUIRED_INCLUDES})
6 set(CMAKE_REQUIRED_LIBRARIES "${GMP_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}")
7 set(CMAKE_REQUIRED_INCLUDES "${GMP_INCLUDE_DIR} ${CMAKE_REQUIRED_INCLUDES}")
9 CHECK_CXX_SOURCE_COMPILES("
11 template<bool COND> struct Static_Assert;
12 template<> struct Static_Assert<true> { };
13 #if defined(__GMP_BITS_PER_MP_LIB)
14 Static_Assert<8*sizeof(mp_limb_t) == __GMP_BITS_PER_MP_LIB> check;
15 int main() { return 0; }
20 if (${cl_gmp_has_nails})
21 message(SEND_ERROR "nails in MP limbs are not supported.")
24 CHECK_CXX_SOURCE_COMPILES("
26 template<bool COND> struct Static_Assert;
27 template<> struct Static_Assert<true> { };
28 Static_Assert<sizeof(mp_limb_t) == sizeof(long)> check;
29 int main() { return 0; }
34 CHECK_CXX_SOURCE_COMPILES("
36 template<bool COND> struct Static_Assert;
37 template<> struct Static_Assert<true> { };
38 Static_Assert<sizeof(mp_limb_t) == sizeof(long long)> check;
39 int main() { return 0; }
41 mp_limb_t_is_long_long
43 set(CMAKE_REQUIRED_INCLUDES ${_save_required_includes})
44 set(CMAKE_REQUIRED_LIBRARIES ${_save_required_libraries})
46 if (mp_limb_t_is_long)
47 message(STATUS "sizeof(mp_limb_t) == sizeof(long)")
48 set(GMP_DEMANDS_UINTD_LONG 1 CACHE INTERNAL "sizeof(mp_limb_t) == sizeof(long)")
49 else (mp_limb_t_is_long)
50 if (mp_limb_t_is_long_long)
51 message(STATUS "sizeof(mp_limb_t) == sizeof(long long)")
52 set(GMP_DEMANDS_UINTD_LONG_LONG 1 CACHE INTERNAL "sizeof(mp_limb_t) == sizeof(long long)")
54 message(SEND_ERROR "Don't know which C integer type has sizeof(mp_limb_t)")
56 endif (mp_limb_t_is_long)