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.

system.cmake 3.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ##
  2. ## Author: Hank Anderson <hank@statease.com>
  3. ## Copyright: (c) Stat-Ease, Inc.
  4. ## Created: 12/29/14
  5. ## Last Modified: 12/29/14
  6. ## Description: Ported from OpenBLAS/Makefile.system
  7. ##
  8. set(NETLIB_LAPACK_DIR "${CMAKE_SOURCE_DIR}/lapack-netlib")
  9. # TODO: Makefile.system detects Darwin (mac) and switches to clang here -hpa
  10. # http://stackoverflow.com/questions/714100/os-detecting-makefile
  11. # TODO: Makefile.system sets HOSTCC = $(CC) here if not already set -hpa
  12. # TARGET_CORE will override TARGET which is used in DYNAMIC_ARCH=1.
  13. if (DEFINED TARGET_CORE)
  14. set(TARGET ${TARGET_CORE})
  15. endif ()
  16. # Force fallbacks for 32bit
  17. if (DEFINED BINARY AND DEFINED TARGET AND BINARY EQUAL 32)
  18. message(STATUS "Compiling a ${BINARY}-bit binary.")
  19. set(NO_AVX 1)
  20. if (${TARGET} STREQUAL "HASWELL" OR ${TARGET} STREQUAL "SANDYBRIDGE")
  21. set(TARGET "NEHALEM")
  22. endif ()
  23. if (${TARGET} STREQUAL "BULLDOZER" OR ${TARGET} STREQUAL "PILEDRIVER")
  24. set(TARGET "BARCELONA")
  25. endif ()
  26. endif ()
  27. if (DEFINED TARGET)
  28. message(STATUS "Targetting the ${TARGET} architecture.")
  29. set(GETARCH_FLAGS "-DFORCE_${TARGET}")
  30. endif ()
  31. if (${INTERFACE64})
  32. message(STATUS "Using 64-bit integers.")
  33. set(GETARCH_FLAGS "${GETARCH_FLAGS} -DUSE64BITINT")
  34. endif ()
  35. if (NOT DEFINED GEMM_MULTITHREAD_THRESHOLD)
  36. set(GEMM_MULTITHREAD_THRESHOLD 4)
  37. endif ()
  38. message(STATUS "GEMM multithread threshold set to ${GEMM_MULTITHREAD_THRESHOLD}.")
  39. set(GETARCH_FLAGS "${GETARCH_FLAGS} -DGEMM_MULTITHREAD_THRESHOLD=${GEMM_MULTITHREAD_THRESHOLD}")
  40. if (${NO_AVX})
  41. message(STATUS "Disabling Advanced Vector Extensions (AVX).")
  42. set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX")
  43. endif ()
  44. if (${NO_AVX2})
  45. message(STATUS "Disabling Advanced Vector Extensions 2 (AVX2).")
  46. set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX2")
  47. endif ()
  48. if (CMAKE_BUILD_TYPE STREQUAL Debug)
  49. set(GETARCH_FLAGS "${GETARCH_FLAGS} -g")
  50. endif ()
  51. # TODO: let CMake handle this? -hpa
  52. #if (${QUIET_MAKE})
  53. # set(MAKE "${MAKE} -s")
  54. #endif()
  55. if (NOT DEFINED NO_PARALLEL_MAKE)
  56. set(NO_PARALLEL_MAKE 0)
  57. endif ()
  58. set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_PARALLEL_MAKE=${NO_PARALLEL_MAKE}")
  59. if (CMAKE_CXX_COMPILER STREQUAL loongcc)
  60. set(GETARCH_FLAGS "${GETARCH_FLAGS} -static")
  61. endif ()
  62. #if don't use Fortran, it will only compile CBLAS.
  63. if (${ONLY_CBLAS})
  64. set(NO_LAPACK 1)
  65. else ()
  66. set(ONLY_CBLAS 0)
  67. endif ()
  68. include("${CMAKE_SOURCE_DIR}/cmake/prebuild.cmake")
  69. if (NOT DEFINED NUM_THREADS)
  70. # TODO: NUM_CORES comes from `getarch.c` or `cpuid_x86.c`. This is built and executed above in `Makefile.prebuild`, and the results are in `Makefile.conf` and `Makefile_kernel.conf`. -hpa
  71. set(NUM_THREADS ${NUM_CORES})
  72. endif ()
  73. if (${NUM_THREADS} EQUAL 1)
  74. # TODO: was "override USE_THREAD = 0", do we need "override" here? -hpa
  75. set(USE_THREAD 0)
  76. endif ()
  77. if (DEFINED USE_THREAD)
  78. if (NOT ${USE_THREAD})
  79. unset(SMP)
  80. else ()
  81. set(SMP 1)
  82. endif ()
  83. else ()
  84. # N.B. this is NUM_THREAD in Makefile.system which is probably a bug -hpa
  85. if (${NUM_THREADS} EQUAL 1)
  86. unset(SMP)
  87. else ()
  88. set(SMP 1)
  89. endif ()
  90. endif ()
  91. if (${SMP})
  92. message(STATUS "SMP enabled.")
  93. endif ()
  94. if (NOT DEFINED NEED_PIC)
  95. set(NEED_PIC 1)
  96. endif ()
  97. # TODO: I think CMake should be handling all this stuff -hpa
  98. unset(ARFLAGS)
  99. set(CPP "${COMPILER} -E")
  100. set(AR "${CROSS_SUFFIX}ar")
  101. set(AS "$(CROSS_SUFFIX)as")
  102. set(LD "$(CROSS_SUFFIX)ld")
  103. set(RANLIB "$(CROSS_SUFFIX)ranlib")
  104. set(NM "$(CROSS_SUFFIX)nm")
  105. set(DLLWRAP "$(CROSS_SUFFIX)dllwrap")
  106. set(OBJCOPY "$(CROSS_SUFFIX)objcopy")
  107. set(OBJCONV "$(CROSS_SUFFIX)objconv")
  108. # TODO: convert rest of Makefile.system, left off at "OS dependent settings"