MinGWCrossCompile.cmake: fix cross builds with recent versions of CMake
[lmms/mlankhorst.git] / cmake / modules / ChecksForLibSamplerate.cmake
blobd3719ca1f8033ce7114bd3ad7e3aaa58b873f256
2 # some tests migrated from libsamplerate's acinclude.m4 - Tobias Doerffel, 2008
5 INCLUDE(CheckCSourceCompiles)
6 INCLUDE(CheckCSourceRuns)
8 SET(CMAKE_REQUIRED_LIBRARIES_ORIG ${CMAKE_REQUIRED_LIBRARIES})
9 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lm)
10 SET(C99_MATH "  #define         _ISOC9X_SOURCE  1
11                 #define         _ISOC99_SOURCE  1
12                 #define         __USE_ISOC99    1
13                 #define         __USE_ISOC9X    1
15                 #include <math.h>
16                                         ")
17 SET(TEST_LRINT "int main( void )
18                 {
19                         if (!lrint(3.14159)) lrint(2.7183);
20                         return( 0 );
21                 }")
22 SET(TEST_LRINTF "int main( void )
23                 {
24                         if (!lrintf(3.14159)) lrintf(2.7183);
25                         return( 0 );
26                 }")
27 CHECK_C_SOURCE_COMPILES("${C99_MATH}${TEST_LRINT}" HAVE_LRINT)
28 CHECK_C_SOURCE_COMPILES("${C99_MATH}${TEST_LRINTF}" HAVE_LRINTF)
31 CHECK_C_SOURCE_RUNS("
32         #define _ISOC9X_SOURCE  1
33         #define _ISOC99_SOURCE  1
34         #define __USE_ISOC99    1
35         #define __USE_ISOC9X    1
36         #include <math.h>
37         int main (void)
38         {       double  fval ;
39                 int k, ival ;
41                 fval = 1.0 * 0x7FFFFFFF ;
42                 for (k = 0 ; k < 100 ; k++)
43                 {       ival = (lrint (fval)) >> 24 ;
44                         if (ival != 127)
45                                 return 1 ;
46                 
47                         fval *= 1.2499999 ;
48                         } ;
49                 
50                         return 0 ;
51                 }
52                                 " CPU_CLIPS_POSITIVE)
53 CHECK_C_SOURCE_RUNS("
54        #define _ISOC9X_SOURCE  1
55         #define _ISOC99_SOURCE  1
56         #define __USE_ISOC99    1
57         #define __USE_ISOC9X    1
58         #include <math.h>
59         int main (void)
60         {       double  fval ;
61                 int k, ival ;
63                 fval = -8.0 * 0x10000000 ;
64                 for (k = 0 ; k < 100 ; k++)
65                 {       ival = (lrint (fval)) >> 24 ;
66                         if (ival != -128)
67                                 return 1 ;
68                 
69                         fval *= 1.2499999 ;
70                         } ;
71                 
72                         return 0 ;
73                 }
74                                 " CPU_CLIPS_NEGATIVE)
75 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIG})