Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Christian Butz
VTK
Commits
c4b4eb3b
Commit
c4b4eb3b
authored
Jul 22, 2013
by
David Gobbi
Committed by
Code Review
Jul 22, 2013
Browse files
Merge topic 'std-isfinite-detection' into master
f808e0c6
14164: Fix incorrectly set VTK_HAS_STD_ISFINITE variable.
parents
0c41fe46
f808e0c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMake/CheckCXXExpressionCompiles.cmake
0 → 100644
View file @
c4b4eb3b
# - Check if a C++ function exists
# CHECK_CXX_EXPRESSION_COMPILES(<expression> <files> <variable>)
#
# Check that the <expression> compiles in a program that includes
# <files> and store the result in a <variable>. Specify the list
# of files in one argument as a semicolon-separated list.
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#=============================================================================
# Copyright 2003-2011 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
INCLUDE
(
CheckCXXSourceCompiles
)
MACRO
(
CHECK_CXX_EXPRESSION_COMPILES EXPRESSION FILES VARIABLE
)
SET
(
SOURCE
"/* CHECK_CXX_EXPRESSION_COMPILES */
\n
"
)
FOREACH
(
FILE
${
FILES
}
)
SET
(
SOURCE
"
${
SOURCE
}
#include <
${
FILE
}
>
\n
"
)
ENDFOREACH
(
FILE
${
FILES
}
)
SET
(
SOURCE
"
${
SOURCE
}
\n
int main()
\n
{
\n
"
)
SET
(
SOURCE
"
${
SOURCE
}
static_cast<void>(
${
EXPRESSION
}
);
\n\n
"
)
SET
(
SOURCE
"
${
SOURCE
}
return 0;
\n
}
\n
"
)
CHECK_CXX_SOURCE_COMPILES
(
"
${
SOURCE
}
"
"
${
VARIABLE
}
"
)
ENDMACRO
(
CHECK_CXX_EXPRESSION_COMPILES
)
Common/Core/CMakeLists.txt
View file @
c4b4eb3b
...
...
@@ -311,13 +311,14 @@ foreach(t Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64)
endforeach
()
# look for various headers and functions
include
(
CheckCXXExpressionCompiles
)
include
(
CheckSymbolExists
)
include
(
CheckIncludeFile
)
# Check C++ <cmath> first, where the C++11 standard says these must be.
check_
symbol_exist
s
(
std::isnan
"cmath"
VTK_HAS_STD_ISNAN
)
check_
symbol_exist
s
(
std::isinf
"cmath"
VTK_HAS_STD_ISINF
)
check_
symbol_exist
s
(
std::isfinite
"cmath"
VTK_HAS_STD_ISFINITE
)
check_
cxx_expression_compile
s
(
"
std::isnan
(0.0)"
"cmath"
VTK_HAS_STD_ISNAN
)
check_
cxx_expression_compile
s
(
"
std::isinf
(0.0)"
"cmath"
VTK_HAS_STD_ISINF
)
check_
cxx_expression_compile
s
(
"
std::isfinite
(0.0)"
"cmath"
VTK_HAS_STD_ISFINITE
)
# Check C99 <math.h> next, where the C99 standard says these must be.
# (they will be found even if they are defined as macros)
...
...
Common/Core/vtkMath.h
View file @
c4b4eb3b
...
...
@@ -1245,8 +1245,11 @@ inline double vtkMath::ClampAndNormalizeValue(double value,
#define VTK_MATH_ISINF_IS_INLINE
inline
int
vtkMath
::
IsInf
(
double
x
)
{
using
namespace
std
;
// Could be isinf() or std::isinf()
#if defined(VTK_HAS_STD_ISINF)
return
std
::
isinf
(
x
);
#else
return
(
isinf
(
x
)
!=
0
);
// Force conversion to bool
#endif
}
#endif
...
...
@@ -1255,8 +1258,11 @@ inline int vtkMath::IsInf(double x)
#define VTK_MATH_ISNAN_IS_INLINE
inline
int
vtkMath
::
IsNan
(
double
x
)
{
using
namespace
std
;
// Could be isnan() or std::isnan()
#if defined(VTK_HAS_STD_ISNAN)
return
std
::
isnan
(
x
);
#else
return
(
isnan
(
x
)
!=
0
);
// Force conversion to bool
#endif
}
#endif
...
...
@@ -1265,8 +1271,9 @@ inline int vtkMath::IsNan(double x)
#define VTK_MATH_ISFINITE_IS_INLINE
inline
bool
vtkMath
::
IsFinite
(
double
x
)
{
#if defined(VTK_HAS_ISFINITE) || defined(VTK_HAS_STD_ISFINITE)
using
namespace
std
;
// Could be isfinite() or std::isfinite()
#if defined(VTK_HAS_STD_ISFINITE)
return
std
::
isfinite
(
x
);
#elif defined(VTK_HAS_ISFINITE)
return
(
isfinite
(
x
)
!=
0
);
// Force conversion to bool
#else
return
(
finite
(
x
)
!=
0
);
// Force conversion to bool
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment