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

c_check.cmake 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ##
  2. ## Author: Hank Anderson <hank@statease.com>
  3. ## Description: Ported from the OpenBLAS/c_check perl script.
  4. ## This is triggered by prebuild.cmake and runs before any of the code is built.
  5. ## Creates config.h and Makefile.conf.
  6. # CMake vars set by this file:
  7. # OSNAME (use CMAKE_SYSTEM_NAME)
  8. # ARCH
  9. # C_COMPILER (use CMAKE_C_COMPILER)
  10. # BINARY32
  11. # BINARY64
  12. # FU
  13. # CROSS_SUFFIX
  14. # CROSS
  15. # CEXTRALIB
  16. # Defines set by this file:
  17. # OS_
  18. # ARCH_
  19. # C_
  20. # __32BIT__
  21. # __64BIT__
  22. # FUNDERSCORE
  23. # PTHREAD_CREATE_FUNC
  24. # N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables.
  25. set(FU "")
  26. if(APPLE)
  27. set(FU "_")
  28. elseif(MSVC)
  29. set(FU "_")
  30. elseif(UNIX)
  31. set(FU "")
  32. endif()
  33. # Convert CMake vars into the format that OpenBLAS expects
  34. string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS)
  35. if (${HOST_OS} STREQUAL "WINDOWS")
  36. set(HOST_OS WINNT)
  37. endif ()
  38. # added by hpa - check size of void ptr to detect 64-bit compile
  39. if (NOT DEFINED BINARY)
  40. set(BINARY 32)
  41. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  42. set(BINARY 64)
  43. endif ()
  44. endif ()
  45. if (BINARY EQUAL 64)
  46. set(BINARY64 1)
  47. else ()
  48. set(BINARY32 1)
  49. endif ()
  50. # CMake docs define these:
  51. # CMAKE_SYSTEM_PROCESSOR - The name of the CPU CMake is building for.
  52. # CMAKE_HOST_SYSTEM_PROCESSOR - The name of the CPU CMake is running on.
  53. #
  54. # TODO: CMAKE_SYSTEM_PROCESSOR doesn't seem to be correct - instead get it from the compiler a la c_check
  55. set(ARCH ${CMAKE_SYSTEM_PROCESSOR})
  56. if (${ARCH} STREQUAL "AMD64")
  57. set(ARCH "x86_64")
  58. endif ()
  59. # If you are using a 32-bit compiler on a 64-bit system CMAKE_SYSTEM_PROCESSOR will be wrong
  60. if (${ARCH} STREQUAL "x86_64" AND BINARY EQUAL 32)
  61. set(ARCH x86)
  62. endif ()
  63. if (${ARCH} STREQUAL "X86")
  64. set(ARCH x86)
  65. endif ()
  66. set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
  67. if (${COMPILER_ID} STREQUAL "GNU")
  68. set(COMPILER_ID "GCC")
  69. endif ()
  70. string(TOUPPER ${ARCH} UC_ARCH)
  71. file(WRITE ${TARGET_CONF}
  72. "#define OS_${HOST_OS}\t1\n"
  73. "#define ARCH_${UC_ARCH}\t1\n"
  74. "#define C_${COMPILER_ID}\t1\n"
  75. "#define __${BINARY}BIT__\t1\n"
  76. "#define FUNDERSCORE\t${FU}\n")