From ec8f843fa199fb6f3aa0a35929cd886c4797fd2d Mon Sep 17 00:00:00 2001 From: evpobr Date: Thu, 24 Sep 2020 08:43:47 +0500 Subject: [PATCH] CMake: Cache clip test result --- cmake/ClipMode.cmake | 146 +++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/cmake/ClipMode.cmake b/cmake/ClipMode.cmake index e47497dc..0241e037 100644 --- a/cmake/ClipMode.cmake +++ b/cmake/ClipMode.cmake @@ -2,91 +2,91 @@ include (CheckCSourceRuns) include (CMakePushCheckState) macro (CLIP_MODE) + if ((NOT DEFINED CPU_CLIPS_NEGATIVE) AND (NOT DEFINED CPU_CLIPS_POSITIVE)) + set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion") + set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion") - set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion") - set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion") + message (STATUS "Checking processor clipping capabilities...") - message (STATUS "Checking processor clipping capabilities...") + if (CMAKE_CROSSCOMPILING) - if (CMAKE_CROSSCOMPILING) + set (CLIP_MSG "disabled") + set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE}) + set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE}) - set (CLIP_MSG "disabled") - set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE}) - set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE}) + else (NOT CMAKE_CROSSCOMPILING) - else (NOT CMAKE_CROSSCOMPILING) - - cmake_push_check_state () - - set (CMAKE_REQUIRED_QUIET TRUE) - if (LIBM_REQUIRED) - set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY}) - endif () - - check_c_source_runs ( - " - #define _ISOC9X_SOURCE 1 - #define _ISOC99_SOURCE 1 - #define __USE_ISOC99 1 - #define __USE_ISOC9X 1 - #include - int main (void) - { double fval ; - int k, ival ; - - fval = 1.0 * 0x7FFFFFFF ; - for (k = 0 ; k < 100 ; k++) - { ival = (lrint (fval)) >> 24 ; - if (ival != 127) - return 1 ; + cmake_push_check_state () - fval *= 1.2499999 ; - } ; + set (CMAKE_REQUIRED_QUIET TRUE) + if (LIBM_REQUIRED) + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY}) + endif () - return 0 ; - } - " - CPU_CLIPS_POSITIVE) - - check_c_source_runs ( - " - #define _ISOC9X_SOURCE 1 - #define _ISOC99_SOURCE 1 - #define __USE_ISOC99 1 - #define __USE_ISOC9X 1 - #include - int main (void) - { double fval ; - int k, ival ; + check_c_source_runs ( + " + #define _ISOC9X_SOURCE 1 + #define _ISOC99_SOURCE 1 + #define __USE_ISOC99 1 + #define __USE_ISOC9X 1 + #include + int main (void) + { double fval ; + int k, ival ; - fval = -8.0 * 0x10000000 ; - for (k = 0 ; k < 100 ; k++) - { ival = (lrint (fval)) >> 24 ; - if (ival != -128) - return 1 ; + fval = 1.0 * 0x7FFFFFFF ; + for (k = 0 ; k < 100 ; k++) + { ival = (lrint (fval)) >> 24 ; + if (ival != 127) + return 1 ; + + fval *= 1.2499999 ; + } ; + + return 0 ; + } + " + CPU_CLIPS_POSITIVE) - fval *= 1.2499999 ; - } ; - - return 0 ; - } - " - CPU_CLIPS_NEGATIVE) + check_c_source_runs ( + " + #define _ISOC9X_SOURCE 1 + #define _ISOC99_SOURCE 1 + #define __USE_ISOC99 1 + #define __USE_ISOC9X 1 + #include + int main (void) + { double fval ; + int k, ival ; - cmake_pop_check_state () + fval = -8.0 * 0x10000000 ; + for (k = 0 ; k < 100 ; k++) + { ival = (lrint (fval)) >> 24 ; + if (ival != -128) + return 1 ; + + fval *= 1.2499999 ; + } ; + + return 0 ; + } + " + CPU_CLIPS_NEGATIVE) - if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE)) - set (CLIP_MSG "positive") - elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE)) - set (CLIP_MSG "negative") - elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE) - set (CLIP_MSG "both") - else () - set (CLIP_MSG "none") - endif () + cmake_pop_check_state () - endif (CMAKE_CROSSCOMPILING) + if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE)) + set (CLIP_MSG "positive") + elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE)) + set (CLIP_MSG "negative") + elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE) + set (CLIP_MSG "both") + else () + set (CLIP_MSG "none") + endif () - message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}") + endif (CMAKE_CROSSCOMPILING) + message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}") + endif () endmacro (CLIP_MODE)