UseSystemExtensions.cmake 1.5 KB

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