Skip to content

Commit

Permalink
Check for NAN in CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
thetic committed Aug 19, 2022
1 parent a521a90 commit fbb8526
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
17 changes: 15 additions & 2 deletions CMakeLists.txt
@@ -1,6 +1,7 @@
# 2.6.3 is needed for ctest support
# 3.1 is needed for target_sources
cmake_minimum_required(VERSION 3.1)
# 3.8 is needed for try_compile improvements (CMP0067)
cmake_minimum_required(VERSION 3.8)

project(CppUTest)

Expand Down Expand Up @@ -39,7 +40,6 @@ option(LIBNAME_POSTFIX_BITSIZE "Add architecture bitsize (32/64) to the library
option(LIBNAME_POSTFIX_DEBUG "Add indication of debug compilation to the library name?" OFF)

option(HAS_INF "Compiler has Inf value for float" ON)
option(HAS_NAN "Compiler has NaN value for float" ON)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Don't change users' build type.
# Multi-configuration generators don't have a single build type.
Expand Down Expand Up @@ -124,6 +124,19 @@ if(HAVE_PTHREAD_MUTEX_LOCK)
)
endif(HAVE_PTHREAD_MUTEX_LOCK)

if(DEFINED HAS_NAN)
message(DEPRECATION
"The HAS_NAN cache variable has been deprecated. "
"CPPUTEST_HAS_NAN is assessed automatically, "
"but can be assigned manually."
)
set(CPPUTEST_HAS_NAN ${HAS_NAN})
endif()
if(NOT DEFINED CPPUTEST_HAS_NAN)
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(NAN "math.h" CPPUTEST_HAS_NAN)
endif()

if (NOT IAR)
check_function_exists(strdup HAVE_STRDUP)
if(HAVE_STRDUP)
Expand Down
5 changes: 0 additions & 5 deletions cmake/Modules/CppUTestConfigurationOptions.cmake
Expand Up @@ -17,7 +17,6 @@ elseif (BORLAND)
set(MEMORY_LEAK_DETECTION OFF)
set(LONGLONG OFF)
set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -w-8008 -w-8066")
set(HAS_NAN OFF)
elseif (STD_C)
if(NOT CPP_PLATFORM)
set(CPP_PLATFORM Gcc)
Expand Down Expand Up @@ -63,10 +62,6 @@ if (LONGLONG)
set(CPPUTEST_USE_LONG_LONG 1)
endif (LONGLONG)

if (NOT HAS_NAN)
set(CPPUTEST_NO_NAN 1)
endif (NOT HAS_NAN)

if (MAP_FILE AND NOT MSVC)
set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -Wl,-Map,$<.map.txt")
endif (MAP_FILE AND NOT MSVC)
Expand Down
2 changes: 1 addition & 1 deletion config.h.cmake
Expand Up @@ -7,7 +7,7 @@

#cmakedefine CPPUTEST_HAVE_FENV
#cmakedefine01 CPPUTEST_HAS_INF
#cmakedefine CPPUTEST_NO_NAN
#cmakedefine01 CPPUTEST_HAS_NAN

#cmakedefine CPPUTEST_STD_C_LIB_DISABLED
#cmakedefine CPPUTEST_STD_CPP_LIB_DISABLED
Expand Down
2 changes: 2 additions & 0 deletions include/CppUTest/CppUTestConfig.h
Expand Up @@ -347,11 +347,13 @@ typedef struct cpputest_ulonglong cpputest_ulonglong;
#endif
#endif

#ifndef CPPUTEST_HAS_NAN
#if defined(CPPUTEST_NO_NAN)
#define CPPUTEST_HAS_NAN 0
#else
#define CPPUTEST_HAS_NAN 1
#endif
#endif


#endif

0 comments on commit fbb8526

Please sign in to comment.