xref: /aosp_15_r20/external/flac/cmake/UseSystemExtensions.cmake (revision 600f14f40d737144c998e2ec7a483122d3776fbc)
1include(CheckCSourceCompiles)
2
3check_c_source_compiles("
4    #include <wchar.h>
5    mbstate_t x;
6    int main() { return 0; }"
7    HAVE_MBSTATE)
8if(NOT HAVE_MBSTATE)
9    check_c_source_compiles("
10        #define _XOPEN_SOURCE 500
11        #include <wchar.h>
12        mbstate_t x;
13        int main() { return 0; }"
14        DODEFINE_XOPEN_SOURCE)
15endif()
16check_c_source_compiles("
17    #define __EXTENSIONS__ 1
18    #include <stdio.h>
19    #ifdef HAVE_SYS_TYPES_H
20    # include <sys/types.h>
21    #endif
22    #ifdef HAVE_SYS_STAT_H
23    # include <sys/stat.h>
24    #endif
25    #ifdef STDC_HEADERS
26    # include <stdlib.h>
27    # include <stddef.h>
28    #else
29    # ifdef HAVE_STDLIB_H
30    #  include <stdlib.h>
31    # endif
32    #endif
33    #ifdef HAVE_STRING_H
34    # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
35    #  include <memory.h>
36    # endif
37    # include <string.h>
38    #endif
39    #ifdef HAVE_STRINGS_H
40    # include <strings.h>
41    #endif
42    #ifdef HAVE_INTTYPES_H
43    # include <inttypes.h>
44    #endif
45    #ifdef HAVE_STDINT_H
46    # include <stdint.h>
47    #endif
48    #ifdef HAVE_UNISTD_H
49    # include <unistd.h>
50    #endif
51    int main() { return 0; }"
52    DODEFINE_EXTENSIONS)
53
54add_definitions(
55    -D_DARWIN_C_SOURCE
56    -D_POSIX_PTHREAD_SEMANTICS
57    -D__STDC_WANT_IEC_60559_BFP_EXT__
58    -D__STDC_WANT_IEC_60559_DFP_EXT__
59    -D__STDC_WANT_IEC_60559_FUNCS_EXT__
60    -D__STDC_WANT_IEC_60559_TYPES_EXT__
61    -D__STDC_WANT_LIB_EXT2__
62    -D__STDC_WANT_MATH_SPEC_FUNCS__
63    -D_TANDEM_SOURCE)
64