You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.8 KiB

  1. #
  2. # Check for platform specific features and generate configuration header..
  3. #
  4. # This cmake file was written to create a platform specific configuration
  5. # header to handle differences between build platforms. Please add new
  6. # feature checks to this file. Always check the wxWidgets headers first
  7. # before adding new feature checks. The wxWidgets build system does a
  8. # very good job of handling platform and compiler differences.
  9. #
  10. # Should you feel the need to do this:
  11. #
  12. # #ifdef SYSTEM_A
  13. # # include <some_header_for_system_a.h>
  14. # #elif SYSTEM_B
  15. # # include <some_other_header_for_system_b.h>
  16. # #elif SYSTEM_C
  17. # # include <yet_another_header_for_system_c.h>
  18. # #endif
  19. #
  20. # in your source, don't. It is not portable nor is it maintainable.
  21. # Use cmake to detect system specific dependencies and update the
  22. # configuration header instead.
  23. #
  24. # See this link for information on writing cmake system checks:
  25. #
  26. # http://www.vtk.org/Wiki/CMake_HowToDoPlatformChecks
  27. #
  28. # More importantly see "Recommendations for Writing Autoconf Macros" in:
  29. #
  30. # http://www.lrde.epita.fr/~adl/dl/autotools.pdf
  31. #
  32. # for an explanation of why you should do this. Even though this is an
  33. # autotools tutorial. This section clearly explains why checking for
  34. # features is superior to checking for systems. The previous section of
  35. # this tutorial shows how to create a system independent check for _mkdir().
  36. # Consider it a benchmark when writing your own feature tests.
  37. #
  38. macro( perform_feature_checks )
  39. include( CheckIncludeFile )
  40. #include( CheckFunctionExists )
  41. include( CheckLibraryExists )
  42. include( CheckSymbolExists )
  43. include( CheckIncludeFileCXX )
  44. include( CheckCXXSymbolExists )
  45. include( CheckCXXSourceCompiles )
  46. include( CheckCXXCompilerFlag )
  47. check_include_file( "malloc.h" HAVE_MALLOC_H )
  48. # FIXME: Visual C++ does not support the "not" keyword natively. It is
  49. # defined as a macro in <iso646.h>. There should be a cmake macro
  50. # to check if compiler supports the not keyword natively. If not,
  51. # then check for <iso646.h> and include it. Although it doesn't
  52. # appear to cause any problems with other compilers, that doesn't
  53. # mean won't fail somewhere down the line.
  54. check_include_file( "iso646.h" HAVE_ISO646_H )
  55. # The STDINT header file test is required because MinGW under Windows
  56. # doesn't define HAVE_STDINT_H even though it does have it.
  57. #
  58. # We need to add it to the global compiler definitions as config.h is not
  59. # included in pyport.h which is where the problem ocurrs without this
  60. # fix.
  61. check_include_file( "stdint.h" HAVE_STDINT_H )
  62. if( HAVE_STDINT_H )
  63. add_definitions( -DHAVE_STDINT_H )
  64. endif()
  65. # no place is this used, and "HAVE_STRINGS_H", if present in config.h then
  66. # conflicts with /usr/include/python2.6/Python.h. Please rename the macro if
  67. # re-introduce this.
  68. # check_include_file("strings.h" HAVE_STRINGS_H)
  69. check_symbol_exists( strcasecmp "string.h" HAVE_STRCASECMP )
  70. check_symbol_exists( strcasecmp "strings.h" HAVE_STRCASECMP )
  71. check_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP )
  72. check_symbol_exists( strncasecmp "strings.h" HAVE_STRNCASECMP )
  73. check_symbol_exists( strtok_r "string.h" HAVE_STRTOKR )
  74. check_cxx_symbol_exists( strcasecmp "string.h" HAVE_STRCASECMP )
  75. check_cxx_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP )
  76. # Some platforms define malloc and free in malloc.h instead of stdlib.h.
  77. check_symbol_exists( malloc "stdlib.h" MALLOC_IN_STDLIB_H )
  78. # Check for functions in math.h.
  79. check_include_file( "math.h" HAVE_MATH_H )
  80. # Check for functions in C++ cmath.
  81. check_include_file_cxx( cmath HAVE_CXX_CMATH )
  82. check_cxx_symbol_exists( asinh cmath HAVE_CMATH_ASINH )
  83. check_cxx_symbol_exists( acosh cmath HAVE_CMATH_ACOSH )
  84. check_cxx_symbol_exists( atanh cmath HAVE_CMATH_ATANH )
  85. # CMakes check_cxx_symbol_exists() doesn't work for templates so we must create a
  86. # small program to verify isinf() exists in cmath.
  87. check_cxx_source_compiles( "#include <cmath>\nint main(int argc, char** argv)\n{\n (void)argv;\n std::isinf(1.0); (void)argc;\n return 0;\n}\n" HAVE_CMATH_ISINF )
  88. #check_symbol_exists( clock_gettime "time.h" HAVE_CLOCK_GETTIME ) non-standard library, does not work
  89. check_library_exists( rt clock_gettime "" HAVE_CLOCK_GETTIME )
  90. # HAVE_GETTIMEOFDAY is already in use within 2.9 wxWidgets, so use HAVE_GETTIMEOFDAY_FUNC
  91. check_symbol_exists( gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY_FUNC )
  92. # Check for Posix getc_unlocked() for improved performance over getc(). Fall back to
  93. # getc() on platforms where getc_unlocked() doesn't exist.
  94. check_symbol_exists( getc_unlocked "stdio.h" HAVE_FGETC_NOLOCK )
  95. endmacro( perform_feature_checks )