11include (CheckCCompilerFlag )
22include (CheckCSourceCompiles )
3+ include (CheckCXXSourceCompiles )
34include (CheckTypeSize )
45include (CheckLanguage )
56
@@ -12,7 +13,6 @@ if (SLEEF_BUILD_STATIC_TEST_BINS)
1213endif ()
1314
1415if (NOT SLEEF_DISABLE_SSL)
15- set (OPENSSL_EXTRA_LIBRARIES "" CACHE STRING "Extra libraries for openssl" )
1616 if (NOT CMAKE_CROSSCOMPILING AND NOT SLEEF_FORCE_FIND_PACKAGE_SSL)
1717 if (SLEEF_BUILD_STATIC_TEST_BINS)
1818 set (OPENSSL_USE_STATIC_LIBS TRUE )
@@ -223,7 +223,7 @@ if(NOT CLANG_EXE_PATH)
223223 set (CLANG_EXE_PATH ${CMAKE_C_COMPILER} )
224224 else ()
225225 # Else we may find clang on the path?
226- find_program (CLANG_EXE_PATH NAMES clang "clang-11 " "clang-10 " "clang-9 " "clang-8 " "clang-7 " "clang-6.0 " "clang-5.0 " "clang-4.0 " "clang-3.9 " )
226+ find_program (CLANG_EXE_PATH NAMES clang "clang-25 " "clang-24 " "clang-23 " "clang-22 " "clang-21 " "clang-20 " "clang-19 " "clang-18 " "clang-17 " )
227227 endif ()
228228endif ()
229229
@@ -410,9 +410,6 @@ endif()
410410
411411# Long double
412412
413- option (SLEEF_DISABLE_LONG_DOUBLE "Disable long double" OFF )
414- option (SLEEF_ENFORCE_LONG_DOUBLE "Build fails if long double is not supported by the compiler" OFF )
415-
416413if (NOT SLEEF_DISABLE_LONG_DOUBLE)
417414 CHECK_TYPE_SIZE ("long double" LD_SIZE )
418415 if (LD_SIZE GREATER "9" )
@@ -433,9 +430,6 @@ endif()
433430
434431# float128
435432
436- option (SLEEF_DISABLE_FLOAT128 "Disable float128" OFF )
437- option (SLEEF_ENFORCE_FLOAT128 "Build fails if float128 is not supported by the compiler" OFF )
438-
439433if (NOT SLEEF_DISABLE_FLOAT128)
440434 CHECK_C_SOURCE_COMPILES ("
441435 int main() { __float128 r = 1;
@@ -455,10 +449,37 @@ if(COMPILER_SUPPORTS_FLOAT128)
455449 }" COMPILER_SUPPORTS_QUADMATH )
456450endif ()
457451
458- # SSE2
452+ if (COMPILER_SUPPORTS_FLOAT128)
453+ if (CMAKE_CXX_COMPILER_TARGET)
454+ set (CMAKE_REQUIRED_FLAGS "--target=${CMAKE_CXX_COMPILER_TARGET} " )
455+ endif ()
456+ CHECK_CXX_SOURCE_COMPILES ("
457+ #include <bit>
458+ struct s { long long x, y; };
459+ int main(int argc, char **argv) {
460+ constexpr s a = std::bit_cast<s>(__float128(0.1234)*__float128(56.789));
461+ static_assert((a.x ^ a.y) == 0xc7d695c93a4e2b71LL);
462+ __float128 i = argc;
463+ return (int)i;
464+ }
465+ " SLEEF_FLOAT128_IS_IEEEQP )
466+ set (CMAKE_REQUIRED_FLAGS)
467+ endif ()
468+
469+ if (CMAKE_CXX_COMPILER_TARGET)
470+ set (CMAKE_REQUIRED_FLAGS "--target=${CMAKE_CXX_COMPILER_TARGET} " )
471+ endif ()
472+ CHECK_CXX_SOURCE_COMPILES ("
473+ #include <bit>
474+ struct s { long long x, y; };
475+ int main(void) {
476+ constexpr s a = std::bit_cast<s>((long double)0.1234*(long double)56.789);
477+ static_assert((a.x ^ a.y) == 0xc7d695c93a4e2b71LL);
478+ }
479+ " SLEEF_LONGDOUBLE_IS_IEEEQP )
480+ set (CMAKE_REQUIRED_FLAGS)
459481
460- option (SLEEF_DISABLE_SSE2 "Disable SSE2" OFF )
461- option (SLEEF_ENFORCE_SSE2 "Build fails if SSE2 is not supported by the compiler" OFF )
482+ # SSE2
462483
463484if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE2)
464485 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_SSE2} " )
@@ -479,9 +500,6 @@ endif()
479500
480501# SSE 4.1
481502
482- option (SLEEF_DISABLE_SSE4 "Disable SSE4" OFF )
483- option (SLEEF_ENFORCE_SSE4 "Build fails if SSE4 is not supported by the compiler" OFF )
484-
485503if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE4)
486504 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_SSE4} " )
487505 CHECK_C_SOURCE_COMPILES ("
@@ -501,9 +519,6 @@ endif()
501519
502520# AVX
503521
504- option (SLEEF_ENFORCE_AVX "Disable AVX" OFF )
505- option (SLEEF_ENFORCE_AVX "Build fails if AVX is not supported by the compiler" OFF )
506-
507522if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX)
508523 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX} " )
509524 CHECK_C_SOURCE_COMPILES ("
@@ -523,9 +538,6 @@ endif()
523538
524539# FMA4
525540
526- option (SLEEF_DISABLE_FMA4 "Disable FMA4" OFF )
527- option (SLEEF_ENFORCE_FMA4 "Build fails if FMA4 is not supported by the compiler" OFF )
528-
529541if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_FMA4)
530542 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_FMA4} " )
531543 CHECK_C_SOURCE_COMPILES ("
@@ -545,9 +557,6 @@ endif()
545557
546558# AVX2
547559
548- option (SLEEF_DISABLE_AVX2 "Disable AVX2" OFF )
549- option (SLEEF_ENFORCE_AVX2 "Build fails if AVX2 is not supported by the compiler" OFF )
550-
551560if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX2)
552561 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX2} " )
553562 CHECK_C_SOURCE_COMPILES ("
@@ -572,8 +581,6 @@ endif()
572581
573582# AVX512F
574583
575- option (SLEEF_DISABLE_AVX512F "Disable AVX512F" OFF )
576- option (SLEEF_ENFORCE_AVX512F "Build fails if AVX512F is not supported by the compiler" OFF )
577584
578585if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX512F)
579586 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX512F} " )
@@ -604,9 +611,6 @@ endif()
604611
605612# SVE
606613
607- option (SLEEF_DISABLE_SVE "Disable SVE" OFF )
608- option (SLEEF_ENFORCE_SVE "Build fails if SVE is not supported by the compiler" OFF )
609-
610614# Darwin does not support SVE yet (see issue #474),
611615# therefore we disable SVE on Darwin systems.
612616if (SLEEF_ARCH_AARCH64 AND NOT SLEEF_DISABLE_SVE AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
@@ -628,9 +632,6 @@ endif()
628632
629633# VSX
630634
631- option (SLEEF_DISABLE_VSX "Disable VSX" OFF )
632- option (SLEEF_ENFORCE_VSX "Build fails if VSX is not supported by the compiler" OFF )
633-
634635if (SLEEF_ARCH_PPC64 AND NOT SLEEF_DISABLE_VSX)
635636 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VSX} " )
636637 CHECK_C_SOURCE_COMPILES ("
@@ -658,9 +659,6 @@ endif()
658659
659660# VSX3
660661
661- option (SLEEF_DISABLE_VSX3 "Disable VSX3" OFF )
662- option (SLEEF_ENFORCE_VSX3 "Build fails if VSX3 is not supported by the compiler" OFF )
663-
664662if (SLEEF_ARCH_PPC64 AND NOT SLEEF_DISABLE_VSX3)
665663 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VSX3} " )
666664 CHECK_C_SOURCE_COMPILES ("
@@ -687,9 +685,6 @@ endif()
687685
688686# IBM Z
689687
690- option (SLEEF_DISABLE_VXE "Disable VXE" OFF )
691- option (SLEEF_ENFORCE_VXE "Build fails if VXE is not supported by the compiler" OFF )
692-
693688if (SLEEF_ARCH_S390X AND NOT SLEEF_DISABLE_VXE)
694689 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VXE} " )
695690 CHECK_C_SOURCE_COMPILES ("
@@ -711,9 +706,6 @@ endif()
711706
712707#
713708
714- option (SLEEF_DISABLE_VXE2 "Disable VXE2" OFF )
715- option (SLEEF_ENFORCE_VXE2 "Build fails if VXE2 is not supported by the compiler" OFF )
716-
717709if (SLEEF_ARCH_S390X AND NOT SLEEF_DISABLE_VXE2)
718710 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VXE2} " )
719711 CHECK_C_SOURCE_COMPILES ("
@@ -735,9 +727,6 @@ endif()
735727
736728# RVVM1
737729
738- option (SLEEF_DISABLE_RVVM1 "Disable RVVM1" OFF )
739- option (SLEEF_ENFORCE_RVVM1 "Build fails if RVVM1 is not supported by the compiler" OFF )
740-
741730if (SLEEF_ARCH_RISCV64 AND NOT SLEEF_DISABLE_RVVM1)
742731 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_RVVM1} " )
743732 CHECK_C_SOURCE_COMPILES ("
@@ -771,9 +760,6 @@ endif()
771760
772761# RVVM2
773762
774- option (SLEEF_DISABLE_RVVM2 "Disable RVVM2" OFF )
775- option (SLEEF_ENFORCE_RVVM2 "Build fails if RVVM2 is not supported by the compiler" OFF )
776-
777763if (SLEEF_ARCH_RISCV64 AND NOT SLEEF_DISABLE_RVVM2)
778764 string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_RVVM2} " )
779765 CHECK_C_SOURCE_COMPILES ("
@@ -807,17 +793,12 @@ endif()
807793
808794# CUDA
809795
810- option (SLEEF_ENFORCE_CUDA "Build fails if CUDA is not supported" OFF )
811-
812796if (SLEEF_ENFORCE_CUDA AND NOT CMAKE_CUDA_COMPILER)
813797 message (FATAL_ERROR "SLEEF_ENFORCE_CUDA is specified and that feature is disabled or not supported by the compiler" )
814798endif ()
815799
816800# OpenMP
817801
818- option (SLEEF_DISABLE_OPENMP "Disable OPENMP" OFF )
819- option (SLEEF_ENFORCE_OPENMP "Build fails if OPENMP is not supported by the compiler" OFF )
820-
821802if (NOT SLEEF_DISABLE_OPENMP)
822803 find_package (OpenMP )
823804 # Check if compilation with OpenMP really succeeds
0 commit comments