Debian Codegraph @

cmake/tribits/core/config_tests/FiniteValue.cmake

raw
1 # @HEADER
2 # *****************************************************************************
3 # TriBITS: Tribal Build, Integrate, and Test System
4 #
5 # Copyright 2013-2016 NTESS and the TriBITS contributors.
6 # SPDX-License-Identifier: BSD-3-Clause
7 # *****************************************************************************
8 # @HEADER
9
10 # Checks for the isnan() and isinf() functions needed by Trilinos.
11 # These functions are not supported reliably across all platforms.
12 # Even if they are supported, they sometimes don't have a prototype
13 # defined in a header, making it useless in c++.
14
15 # We check for a predefined version and use that. If not, then we
16 # fall back on checks that may or may not work depending on the
17 # platforms's compliance with IEEE standards.
18
19 include(CheckCXXSourceRuns)
20 include(CheckCXXSourceCompiles)
21
22 #############################################################
23 # isnan
24 #############################################################
25
26 # Some machines have isnan() in the global namespace and some put it
27 # in the std:: namespace. We will check for both.
28
29 set(SOURCE_GLOBAL_ISNAN
30 "
31 #include <cmath>
32 int main()
33 {
34 double x = 1.0;
35 isnan(x);
36 return 0;
37 }
38 "
39 )
40
41 check_cxx_source_compiles("${SOURCE_GLOBAL_ISNAN}"
42 FINITE_VALUE_HAVE_GLOBAL_ISNAN)
43
44 set(SOURCE_STD_ISNAN
45 "
46 #include <cmath>
47 int main()
48 {
49 double x = 1.0;
50 std::isnan(x);
51 return 0;
52 }
53 "
54 )
55
56 check_cxx_source_compiles("${SOURCE_STD_ISNAN}"
57 FINITE_VALUE_HAVE_STD_ISNAN)
58
59 if (CMAKE_VERBOSE_MAKEFILE)
60 if (NOT FINITE_VALUE_HAVE_GLOBAL_ISNAN AND
61 NOT FINITE_VALUE_HAVE_STD_ISNAN )
62 message("****************************************************")
63 message("** NOTE: Your compiler doesn't support isnan() or")
64 message("** std::isnan()")
65 message("** We will supply a default checker but it is ")
66 message("** *NOT* guaranteed to work on your platform")
67 message("** unless your machine is IEEE 748/754 compliant.")
68 message("****************************************************")
69 endif()
70 endif()
71
72 #############################################################
73 # isinf
74 #############################################################
75
76 set(SOURCE_GLOBAL_ISINF
77 "
78 #include <cmath>
79 int main()
80 {
81 double x = 1.0;
82 isinf(x);
83 return 0;
84 }
85 "
86 )
87
88 check_cxx_source_compiles("${SOURCE_GLOBAL_ISINF}"
89 FINITE_VALUE_HAVE_GLOBAL_ISINF)
90
91 set(SOURCE_STD_ISINF
92 "
93 #include <cmath>
94 int main()
95 {
96 double x = 1.0;
97 std::isinf(x);
98 return 0;
99 }
100 "
101 )
102
103 check_cxx_source_compiles("${SOURCE_STD_ISINF}"
104 FINITE_VALUE_HAVE_STD_ISINF)
105
106 if (CMAKE_VERBOSE_MAKEFILE)
107 if (NOT FINITE_VALUE_HAVE_GLOBAL_ISINF AND
108 NOT FINITE_VALUE_HAVE_STD_ISINF )
109 message("****************************************************")
110 message("** NOTE: Your compiler doesn't support isinf() or")
111 message("** std::isinf()")
112 message("** We will supply a default checker but it is ")
113 message("** *NOT* guaranteed to work on your platform")
114 message("** unless your machine is IEEE 748/754 compliant.")
115 message("****************************************************")
116 endif()
117 endif()
118
119 #############################################################
120 #############################################################