Commit c4b4eb3b authored by David Gobbi's avatar David Gobbi Committed by Code Review
Browse files

Merge topic 'std-isfinite-detection' into master

f808e0c6 14164: Fix incorrectly set VTK_HAS_STD_ISFINITE variable.
parents 0c41fe46 f808e0c6
# - 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}\nint 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)
......@@ -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_exists(std::isnan "cmath" VTK_HAS_STD_ISNAN)
check_symbol_exists(std::isinf "cmath" VTK_HAS_STD_ISINF)
check_symbol_exists(std::isfinite "cmath" VTK_HAS_STD_ISFINITE)
check_cxx_expression_compiles("std::isnan(0.0)" "cmath" VTK_HAS_STD_ISNAN)
check_cxx_expression_compiles("std::isinf(0.0)" "cmath" VTK_HAS_STD_ISINF)
check_cxx_expression_compiles("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)
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment