Always reset all variables.
Only require libm if it is avaiable (only on Unix)
Also prefer usage of _finite. ICC on Windows gives warnings
for isfinite (we don't inlude mathimf.h).
Fixes #998
Change-Id: Ib7c064aaf6d26d2ab96f5e88345091a2eb096998
#The user could specify trash in FFTW_LIBRARY, so test if we can link it
include(CheckLibraryExists)
#adding MATH_LIBRARIES here to allow static libs, this does not harm us as we are anyway using it
- set(CMAKE_REQUIRED_LIBRARIES m)
+ if (HAVE_LIBM)
+ set(CMAKE_REQUIRED_LIBRARIES m)
+ endif()
unset(FOUND_FFTW_PLAN_${FFTW_PKG} CACHE)
check_library_exists("${FFTW_LIBRARIES}" "${FFTW_FUNCTION}" "" FOUND_FFTW_PLAN_${FFTW_PKG})
if(NOT FOUND_FFTW_PLAN_${FFTW_PKG})
if (PTHREAD_SETAFFINITY)
set(HAVE_PTHREAD_SETAFFINITY 1)
endif (PTHREAD_SETAFFINITY)
+ set(CMAKE_REQUIRED_LIBRARIES)
endif (THREAD_PTHREADS)
MESSAGE(STATUS "Checking for isfinite")
set(CMAKE_REQUIRED_INCLUDES "math.h")
- set(CMAKE_REQUIRED_LIBRARIES "m")
+ if (HAVE_LIBM)
+ set(CMAKE_REQUIRED_LIBRARIES "m")
+ endif()
check_c_source_compiles(
"#include <math.h>
int main(void) {
MESSAGE(STATUS "Checking for isfinite - no")
endif(isfinite_compile_ok)
set(isfinite_compile_ok "${isfinite_compile_ok}" CACHE INTERNAL "Result of isfinite check")
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_REQUIRED_LIBRARIES)
endif(NOT DEFINED isfinite_compile_ok)
if(isfinite_compile_ok)
set(${VARIABLE} ${isfinite_compile_ok}
MESSAGE(STATUS "Checking for _isfinite")
set(CMAKE_REQUIRED_INCLUDES "math.h")
- set(CMAKE_REQUIRED_LIBRARIES "m")
+ if (HAVE_LIBM)
+ set(CMAKE_REQUIRED_LIBRARIES "m")
+ endif()
check_c_source_compiles(
"#include <math.h>
int main(void) {
MESSAGE(STATUS "Checking for _isfinite - no")
endif(_isfinite_compile_ok)
set(_isfinite_compile_ok "${_isfinite_compile_ok}" CACHE INTERNAL "Result of _isfinite check")
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_REQUIRED_LIBRARIES)
endif(NOT DEFINED _isfinite_compile_ok)
if(_isfinite_compile_ok)
set(${VARIABLE} ${_isfinite_compile_ok}
MESSAGE(STATUS "Checking for _finite - no")
endif(_finite_compile_ok)
set(_finite_compile_ok "${_finite_compile_ok}" CACHE INTERNAL "Result of _finite check")
+ set(CMAKE_REQUIRED_INCLUDES)
endif(NOT DEFINED _finite_compile_ok)
if(_finite_compile_ok)
set(${VARIABLE} ${_finite_compile_ok}
MESSAGE(STATUS "Checking for MPI_IN_PLACE - no")
endif(MPI_IN_PLACE_COMPILE_OK)
set(MPI_IN_PLACE_COMPILE_OK "${MPI_IN_PLACE_COMPILE_OK}" CACHE INTERNAL "Result of mpi_in_place check")
+ set(CMAKE_REQUIRED_DEFINITIONS)
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_REQUIRED_LIBRARIES)
endif()
if (MPI_IN_PLACE_COMPILE_OK)
set(${VARIABLE} ${MPI_IN_PLACE_COMPILE_OK}
MESSAGE(STATUS "Checking for dlopen - not found")
set(${VARIABLE} 0 CACHE INTERNAL "Result of test for dlopen" FORCE)
ENDIF()
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_REQUIRED_LIBRARIES)
ENDIF()
ENDMACRO()
\ No newline at end of file
/* If no suitable function was found, assume the value is
* finite. */
-#ifdef HAVE_ISFINITE
+#ifdef HAVE__FINITE
+ returnval = _finite(x);
+#elif defined HAVE_ISFINITE
returnval = isfinite(x);
#elif defined HAVE__ISFINITE
returnval = _isfinite(x);
-#elif defined HAVE__FINITE
- returnval = _finite(x);
#endif
return returnval;
}