CMakeBackwardCompatibilityC.cmake 2.54 KB
Newer Older
1 2
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
3

4

5
if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
6 7
  # Old CMake versions did not support OS X universal binaries anyway,
  # so just get through this with at least some size for the types.
8 9 10 11 12 13 14 15 16 17
  list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHS)
  if(${NUM_ARCHS} GREATER 1)
    if(NOT DEFINED CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
      message(WARNING "This module does not work with OS X universal binaries.")
      set(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES 1)
      list(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
    endif()
  endif()

  include (CheckTypeSize)
18 19 20 21 22 23 24 25
  CHECK_TYPE_SIZE(int      CMAKE_SIZEOF_INT)
  CHECK_TYPE_SIZE(long     CMAKE_SIZEOF_LONG)
  CHECK_TYPE_SIZE("void*"  CMAKE_SIZEOF_VOID_P)
  CHECK_TYPE_SIZE(char     CMAKE_SIZEOF_CHAR)
  CHECK_TYPE_SIZE(short    CMAKE_SIZEOF_SHORT)
  CHECK_TYPE_SIZE(float    CMAKE_SIZEOF_FLOAT)
  CHECK_TYPE_SIZE(double   CMAKE_SIZEOF_DOUBLE)

26
  include (CheckIncludeFile)
27 28 29 30
  CHECK_INCLUDE_FILE("limits.h"       CMAKE_HAVE_LIMITS_H)
  CHECK_INCLUDE_FILE("unistd.h"       CMAKE_HAVE_UNISTD_H)
  CHECK_INCLUDE_FILE("pthread.h"      CMAKE_HAVE_PTHREAD_H)

31
  include (CheckIncludeFiles)
32 33
  CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h"    CMAKE_HAVE_SYS_PRCTL_H)

34
  include (TestBigEndian)
35
  TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
36
  include (FindX11)
37

38
  if("${X11_X11_INCLUDE_PATH}" STREQUAL "/usr/include")
39
    set (CMAKE_X_CFLAGS "" CACHE STRING "X11 extra flags.")
40
  else()
41
    set (CMAKE_X_CFLAGS "-I${X11_X11_INCLUDE_PATH}" CACHE STRING
42
         "X11 extra flags.")
43
  endif()
44
  set (CMAKE_X_LIBS "${X11_LIBRARIES}" CACHE STRING
45
       "Libraries and options used in X11 programs.")
46
  set (CMAKE_HAS_X "${X11_FOUND}" CACHE INTERNAL "Is X11 around.")
47

48
  include (FindThreads)
49

50
  set (CMAKE_THREAD_LIBS        "${CMAKE_THREAD_LIBS_INIT}" CACHE STRING
Bill Hoffman's avatar
Bill Hoffman committed
51 52
    "Thread library used.")

53
  set (CMAKE_USE_PTHREADS       "${CMAKE_USE_PTHREADS_INIT}" CACHE BOOL
Bill Hoffman's avatar
Bill Hoffman committed
54 55
     "Use the pthreads library.")

56
  set (CMAKE_USE_WIN32_THREADS  "${CMAKE_USE_WIN32_THREADS_INIT}" CACHE BOOL
Bill Hoffman's avatar
Bill Hoffman committed
57 58
       "Use the win32 thread library.")

59
  set (CMAKE_HP_PTHREADS        ${CMAKE_HP_PTHREADS_INIT} CACHE BOOL
Bill Hoffman's avatar
Bill Hoffman committed
60 61
     "Use HP pthreads.")

62 63 64 65
  if(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
    set(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
    set(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
  endif()
66
endif()
Bill Hoffman's avatar
Bill Hoffman committed
67

68
mark_as_advanced(
69
CMAKE_HP_PTHREADS
Bill Hoffman's avatar
Bill Hoffman committed
70 71
CMAKE_THREAD_LIBS
CMAKE_USE_PTHREADS
72 73 74 75
CMAKE_USE_WIN32_THREADS
CMAKE_X_CFLAGS
CMAKE_X_LIBS
)
Bill Hoffman's avatar
Bill Hoffman committed
76