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.

CMakeLists.txt 4.5 kB

5 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. include_directories(${PROJECT_SOURCE_DIR})
  2. include_directories(${PROJECT_BINARY_DIR})
  3. if (NOT NOFORTRAN)
  4. enable_language(Fortran)
  5. endif()
  6. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DADD${BU} -DCBLAS")
  7. if (BINARY32 AND CMAKE_C_PLATFORM_ID MATCHES "MinGW" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 14.1)
  8. list(REMOVE_ITEM ${CMAKE_Fortran_FLAGS} -O3 -O2 -O1 -Os)
  9. set (CMAKE_Fortran_FLAGS_RELEASE "" CACHE STRING "" FORCE)
  10. endif()
  11. if (CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
  12. set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-tree-vectorize")
  13. endif()
  14. if(WIN32)
  15. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.ps1
  16. "$ErrorActionPreference = \"Stop\"\n"
  17. "Get-Content $args[1] | & $args[0]\n"
  18. )
  19. set(test_helper powershell -ExecutionPolicy Bypass "${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.ps1")
  20. else()
  21. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.sh
  22. "$1 < $2\n"
  23. )
  24. set(test_helper sh "${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.sh")
  25. endif()
  26. foreach(float_type ${FLOAT_TYPES})
  27. string(SUBSTRING ${float_type} 0 1 float_char_upper)
  28. string(TOLOWER ${float_char_upper} float_char)
  29. if (${float_char} STREQUAL "b")
  30. continue()
  31. endif()
  32. #level1
  33. if (NOT NOFORTRAN)
  34. add_executable(x${float_char}cblat1
  35. c_${float_char}blat1.f
  36. c_${float_char}blas1.c)
  37. else()
  38. add_executable(x${float_char}cblat1
  39. c_${float_char}blat1c.c
  40. c_${float_char}blas1.c)
  41. endif()
  42. target_link_libraries(x${float_char}cblat1 ${OpenBLAS_LIBNAME})
  43. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
  44. target_link_libraries(x${float_char}cblat1 m)
  45. endif()
  46. add_test(NAME "x${float_char}cblat1"
  47. COMMAND $<TARGET_FILE:x${float_char}cblat1>)
  48. #level2
  49. if (NOT NOFORTRAN)
  50. add_executable(x${float_char}cblat2
  51. c_${float_char}blat2.f
  52. c_${float_char}blas2.c
  53. c_${float_char}2chke.c
  54. auxiliary.c
  55. c_xerbla.c
  56. constant.c)
  57. else()
  58. add_executable(x${float_char}cblat2
  59. c_${float_char}blat2c.c
  60. c_${float_char}blas2.c
  61. c_${float_char}2chke.c
  62. auxiliary.c
  63. c_xerbla.c
  64. constant.c)
  65. endif()
  66. target_link_libraries(x${float_char}cblat2 ${OpenBLAS_LIBNAME})
  67. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
  68. target_link_libraries(x${float_char}cblat2 m)
  69. endif()
  70. add_test(NAME "x${float_char}cblat2"
  71. COMMAND ${test_helper} $<TARGET_FILE:x${float_char}cblat2> "${PROJECT_SOURCE_DIR}/ctest/${float_char}in2")
  72. #level3
  73. if (NOT NOFORTRAN)
  74. add_executable(x${float_char}cblat3
  75. c_${float_char}blat3.f
  76. c_${float_char}blas3.c
  77. c_${float_char}3chke.c
  78. auxiliary.c
  79. c_xerbla.c
  80. constant.c)
  81. if (USE_GEMM3M)
  82. if ((${float_char} STREQUAL "c") OR (${float_char} STREQUAL "z"))
  83. add_executable(x${float_char}cblat3_3m
  84. c_${float_char}blat3_3m.f
  85. c_${float_char}blas3_3m.c
  86. c_${float_char}3chke_3m.c
  87. auxiliary.c
  88. c_xerbla.c
  89. constant.c)
  90. endif()
  91. endif()
  92. else()
  93. add_executable(x${float_char}cblat3
  94. c_${float_char}blat3c.c
  95. c_${float_char}blas3.c
  96. c_${float_char}3chke.c
  97. auxiliary.c
  98. c_xerbla.c
  99. constant.c)
  100. if (USE_GEMM3M)
  101. if ((${float_char} STREQUAL "c") OR (${float_char} STREQUAL "z"))
  102. add_executable(x${float_char}cblat3_3m
  103. c_${float_char}blat3c_3m.c
  104. c_${float_char}blas3_3m.c
  105. c_${float_char}3chke_3m.c
  106. auxiliary.c
  107. c_xerbla.c
  108. constant.c)
  109. endif()
  110. endif()
  111. endif()
  112. target_link_libraries(x${float_char}cblat3 ${OpenBLAS_LIBNAME})
  113. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
  114. target_link_libraries(x${float_char}cblat3 m)
  115. endif()
  116. if (USE_GEMM3M)
  117. if ((${float_char} STREQUAL "c") OR (${float_char} STREQUAL "z"))
  118. target_link_libraries(x${float_char}cblat3_3m ${OpenBLAS_LIBNAME})
  119. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
  120. target_link_libraries(x${float_char}cblat3_3m m)
  121. endif()
  122. endif()
  123. endif()
  124. add_test(NAME "x${float_char}cblat3"
  125. COMMAND ${test_helper} $<TARGET_FILE:x${float_char}cblat3> "${PROJECT_SOURCE_DIR}/ctest/${float_char}in3")
  126. if (USE_GEMM3M)
  127. if ((${float_char} STREQUAL "c") OR (${float_char} STREQUAL "z"))
  128. add_test(NAME "x${float_char}cblat3_3m"
  129. COMMAND ${test_helper} $<TARGET_FILE:x${float_char}cblat3_3m> "${PROJECT_SOURCE_DIR}/ctest/${float_char}in3_3m")
  130. endif()
  131. endif()
  132. endforeach()