CMakeBackwardCompatibilityC.cmake 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
  4. # Old CMake versions did not support OS X universal binaries anyway,
  5. # so just get through this with at least some size for the types.
  6. list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHS)
  7. if(${NUM_ARCHS} GREATER 1)
  8. if(NOT DEFINED CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
  9. message(WARNING "This module does not work with OS X universal binaries.")
  10. set(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES 1)
  11. list(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
  12. endif()
  13. endif()
  14. include (CheckTypeSize)
  15. CHECK_TYPE_SIZE(int CMAKE_SIZEOF_INT)
  16. CHECK_TYPE_SIZE(long CMAKE_SIZEOF_LONG)
  17. CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
  18. CHECK_TYPE_SIZE(char CMAKE_SIZEOF_CHAR)
  19. CHECK_TYPE_SIZE(short CMAKE_SIZEOF_SHORT)
  20. CHECK_TYPE_SIZE(float CMAKE_SIZEOF_FLOAT)
  21. CHECK_TYPE_SIZE(double CMAKE_SIZEOF_DOUBLE)
  22. include (CheckIncludeFile)
  23. CHECK_INCLUDE_FILE("limits.h" CMAKE_HAVE_LIMITS_H)
  24. CHECK_INCLUDE_FILE("unistd.h" CMAKE_HAVE_UNISTD_H)
  25. CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
  26. include (CheckIncludeFiles)
  27. CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SYS_PRCTL_H)
  28. include (TestBigEndian)
  29. TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
  30. include (FindX11)
  31. if("${X11_X11_INCLUDE_PATH}" STREQUAL "/usr/include")
  32. set (CMAKE_X_CFLAGS "" CACHE STRING "X11 extra flags.")
  33. else()
  34. set (CMAKE_X_CFLAGS "-I${X11_X11_INCLUDE_PATH}" CACHE STRING
  35. "X11 extra flags.")
  36. endif()
  37. set (CMAKE_X_LIBS "${X11_LIBRARIES}" CACHE STRING
  38. "Libraries and options used in X11 programs.")
  39. set (CMAKE_HAS_X "${X11_FOUND}" CACHE INTERNAL "Is X11 around.")
  40. include (FindThreads)
  41. set (CMAKE_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}" CACHE STRING
  42. "Thread library used.")
  43. set (CMAKE_USE_PTHREADS "${CMAKE_USE_PTHREADS_INIT}" CACHE BOOL
  44. "Use the pthreads library.")
  45. set (CMAKE_USE_WIN32_THREADS "${CMAKE_USE_WIN32_THREADS_INIT}" CACHE BOOL
  46. "Use the win32 thread library.")
  47. set (CMAKE_HP_PTHREADS ${CMAKE_HP_PTHREADS_INIT} CACHE BOOL
  48. "Use HP pthreads.")
  49. if(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
  50. set(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
  51. set(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
  52. endif()
  53. endif()
  54. mark_as_advanced(
  55. CMAKE_HP_PTHREADS
  56. CMAKE_THREAD_LIBS
  57. CMAKE_USE_PTHREADS
  58. CMAKE_USE_WIN32_THREADS
  59. CMAKE_X_CFLAGS
  60. CMAKE_X_LIBS
  61. )