1
1
include (CheckCCompilerFlag)
2
2
include (CheckCSourceCompiles)
3
+ include (CheckCXXSourceCompiles)
3
4
include (CheckTypeSize)
4
5
include (CheckLanguage)
5
6
@@ -12,7 +13,6 @@ if (SLEEF_BUILD_STATIC_TEST_BINS)
12
13
endif ()
13
14
14
15
if (NOT SLEEF_DISABLE_SSL)
15
- set (OPENSSL_EXTRA_LIBRARIES "" CACHE STRING "Extra libraries for openssl" )
16
16
if (NOT CMAKE_CROSSCOMPILING AND NOT SLEEF_FORCE_FIND_PACKAGE_SSL)
17
17
if (SLEEF_BUILD_STATIC_TEST_BINS)
18
18
set (OPENSSL_USE_STATIC_LIBS TRUE )
@@ -223,7 +223,7 @@ if(NOT CLANG_EXE_PATH)
223
223
set (CLANG_EXE_PATH ${CMAKE_C_COMPILER} )
224
224
else ()
225
225
# 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 " )
227
227
endif ()
228
228
endif ()
229
229
@@ -410,9 +410,6 @@ endif()
410
410
411
411
# Long double
412
412
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
-
416
413
if (NOT SLEEF_DISABLE_LONG_DOUBLE)
417
414
CHECK_TYPE_SIZE("long double" LD_SIZE)
418
415
if (LD_SIZE GREATER "9" )
@@ -433,9 +430,6 @@ endif()
433
430
434
431
# float128
435
432
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
-
439
433
if (NOT SLEEF_DISABLE_FLOAT128)
440
434
CHECK_C_SOURCE_COMPILES("
441
435
int main() { __float128 r = 1;
@@ -455,10 +449,37 @@ if(COMPILER_SUPPORTS_FLOAT128)
455
449
}" COMPILER_SUPPORTS_QUADMATH)
456
450
endif ()
457
451
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)
459
481
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
462
483
463
484
if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE2)
464
485
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_SSE2} " )
@@ -479,9 +500,6 @@ endif()
479
500
480
501
# SSE 4.1
481
502
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
-
485
503
if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE4)
486
504
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_SSE4} " )
487
505
CHECK_C_SOURCE_COMPILES("
@@ -501,9 +519,6 @@ endif()
501
519
502
520
# AVX
503
521
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
-
507
522
if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX)
508
523
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX} " )
509
524
CHECK_C_SOURCE_COMPILES("
@@ -523,9 +538,6 @@ endif()
523
538
524
539
# FMA4
525
540
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
-
529
541
if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_FMA4)
530
542
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_FMA4} " )
531
543
CHECK_C_SOURCE_COMPILES("
@@ -545,9 +557,6 @@ endif()
545
557
546
558
# AVX2
547
559
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
-
551
560
if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX2)
552
561
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX2} " )
553
562
CHECK_C_SOURCE_COMPILES("
@@ -572,8 +581,6 @@ endif()
572
581
573
582
# AVX512F
574
583
575
- option (SLEEF_DISABLE_AVX512F "Disable AVX512F" OFF )
576
- option (SLEEF_ENFORCE_AVX512F "Build fails if AVX512F is not supported by the compiler" OFF )
577
584
578
585
if (SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX512F)
579
586
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX512F} " )
@@ -604,9 +611,6 @@ endif()
604
611
605
612
# SVE
606
613
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
-
610
614
# Darwin does not support SVE yet (see issue #474),
611
615
# therefore we disable SVE on Darwin systems.
612
616
if (SLEEF_ARCH_AARCH64 AND NOT SLEEF_DISABLE_SVE AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
@@ -628,9 +632,6 @@ endif()
628
632
629
633
# VSX
630
634
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
-
634
635
if (SLEEF_ARCH_PPC64 AND NOT SLEEF_DISABLE_VSX)
635
636
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VSX} " )
636
637
CHECK_C_SOURCE_COMPILES("
@@ -658,9 +659,6 @@ endif()
658
659
659
660
# VSX3
660
661
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
-
664
662
if (SLEEF_ARCH_PPC64 AND NOT SLEEF_DISABLE_VSX3)
665
663
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VSX3} " )
666
664
CHECK_C_SOURCE_COMPILES("
@@ -687,9 +685,6 @@ endif()
687
685
688
686
# IBM Z
689
687
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
-
693
688
if (SLEEF_ARCH_S390X AND NOT SLEEF_DISABLE_VXE)
694
689
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VXE} " )
695
690
CHECK_C_SOURCE_COMPILES("
@@ -711,9 +706,6 @@ endif()
711
706
712
707
#
713
708
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
-
717
709
if (SLEEF_ARCH_S390X AND NOT SLEEF_DISABLE_VXE2)
718
710
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VXE2} " )
719
711
CHECK_C_SOURCE_COMPILES("
@@ -735,9 +727,6 @@ endif()
735
727
736
728
# RVVM1
737
729
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
-
741
730
if (SLEEF_ARCH_RISCV64 AND NOT SLEEF_DISABLE_RVVM1)
742
731
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_RVVM1} " )
743
732
CHECK_C_SOURCE_COMPILES("
@@ -771,9 +760,6 @@ endif()
771
760
772
761
# RVVM2
773
762
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
-
777
763
if (SLEEF_ARCH_RISCV64 AND NOT SLEEF_DISABLE_RVVM2)
778
764
string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_RVVM2} " )
779
765
CHECK_C_SOURCE_COMPILES("
@@ -807,17 +793,12 @@ endif()
807
793
808
794
# CUDA
809
795
810
- option (SLEEF_ENFORCE_CUDA "Build fails if CUDA is not supported" OFF )
811
-
812
796
if (SLEEF_ENFORCE_CUDA AND NOT CMAKE_CUDA_COMPILER)
813
797
message (FATAL_ERROR "SLEEF_ENFORCE_CUDA is specified and that feature is disabled or not supported by the compiler" )
814
798
endif ()
815
799
816
800
# OpenMP
817
801
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
-
821
802
if (NOT SLEEF_DISABLE_OPENMP)
822
803
find_package (OpenMP)
823
804
# Check if compilation with OpenMP really succeeds
0 commit comments